<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>TeXstudio : user manual</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" type="text/css" href="usermanual.css">
</head>
<body>

<h1 align=center id="top">TeXstudio : User manual</h1>
<h2 id="sommaire">Contents:</h2>
<ul class="two-columns">
<li><a href="#SECTION0">1. Configuring TeXstudio</a>
	<ul>
	<li><a href="#SECTION01">1.1 Configuring the editor</a></li>
	<li><a href="#SECTION02">1.2 Configuring the latex related commands</a></li>
	<li><a href="#SECTION02a">1.3 Configuring the build system</a></li>
	<li><a href="#SECTION030">1.4 Configuring some general issues</a></li>
	<li><a href="#SECTION03">1.4.1 Configuring the spell checker</a></li>
	<li><a href="#SECTION04">1.4.2 Configuring the thesaurus</a></li>
	<li><a href="#SECTION041">1.4.3 Configuring the latex syntax checker</a></li>
	<li><a href="#SECTION044">1.4.4 Configuring the grammar checker</a></li>
	<li><a href="#SECTION040">1.5 Configuring the autocompletion</a></li>
	<li><a href="#SECTION05">1.6 Configuring shortcuts</a></li>
	<li><a href="#SECTION06">1.7 Configuring the Latex/Math-Menu</a></li>
	<li><a href="#SECTION07">1.8 Configuring the Custom Toolbar</a></li>
	<li><a href="#SECTION08">1.9 Configuring SVN support</a></li>
	</ul>
</li>
<li><a href="#SECTION1">2. Editing a TeX document</a>
	<ul>
	<li><a href="#SECTION11">2.1 Usual commands</a></li>
	<li><a href="#SECTION12">2.2 Creating a new document</a></li>
	<li><a href="#SECTION12a">2.2.1 Setting the preamble of a TeX document</a></li>
	<li><a href="#SECTION12b">2.2.2 Using Templates to start a new document</a></li>
	<li><a href="#SECTION13">2.3 Structure of a document</a></li>
	<li><a href="#SECTION14">2.4 Browsing your document</a></li>
	<li><a href="#SECTION15">2.5 Formatting your text</a></li>
	<li><a href="#SECTION16">2.6 Spacings</a></li>
	<li><a href="#SECTION17">2.7 Inserting a list</a></li>
	<li><a href="#SECTION18">2.8 Inserting a table</a></li>
	<li><a href="#SECTION18a">2.8.1 Manipulating a table</a></li>
	<li><a href="#SECTION19">2.9 Inserting a "tabbing" environment</a></li>
	<li><a href="#SECTION110">2.10 Inserting a picture</a></li>
	<li><a href="#SECTION110a">2.10.1 Inserting a picture using a "wizard"</a></li>
	<li><a href="#SECTION111">2.11 Cross References and notes</a></li>
	<li><a href="#SECTION112">2.12 Inserting math formulae</a></li>
	<li><a href="#SECTION113">2.13 Auto completion</a></li>
	<li><a href="#SECTION114">2.14 Thesaurus</a></li>
	<li><a href="#SECTION115">2.15 Special Commands</a></li>
	</ul>
</li>
<li><a href="#SECTION2">3. Compiling a document</a>
	<ul>
	<li><a href="#SECTION22">3.1 Compiling</a></li>
	<li><a href="#SECTION23">3.2 The log files</a></li>
	</ul>
</li>
<li><a href="#SECTION3">4. Other features</a>
	<ul>
	<li><a href="#SECTION31">4.1 About documents separated in several files</a></li>
	<li><a href="#SECTION32a">4.2 Syntax Check</a></li>
	<li><a href="#SECTION32">4.3 Bibliography</a></li>
	<li><a href="#SECTION33a">4.4 SVN Support</a></li>
	<li><a href="#SECTION33">4.5 Personal macros</a></li>
	<li><a href="#SECTION34">4.6 Pstricks support</a></li>
	<li><a href="#SECTION35">4.7 Metapost support</a></li>
	<li><a href="#SECTION36">4.8 The "Convert to Html" command</a></li>
	<li><a href="#SECTION37">4.9 "Forward/Inverse search" with TeXstudio</a></li>
	<li><a href="#TEXCOM">4.10 Advanced header usage</a></li>
	<li><a href="#TEXSTUDIO-CMD">4.11 Synopsis of the TeXstudio command</a></li>
	<li><a href="#SHORTCUTS">4.12 Keyboard shortcuts</a></li>
	<li><a href="#CWLDESCRIPTION">4.13 Description of the cwl format</a></li>
	<li><a href="#TABLETEMPLATE">4.14 Using table templates</a></li>
	</ul>
</li>
<li><a href="#TENTATIVE-FEATURES">5. Experimental Features</a>
	<ul>
	<li><a href="#ADVANCED-SCRIPTING">5.1 Advanced Scripting</a></li>
	<li><a href="#STYLESHEETS">5.2 Style Sheets</a></li>
	<li><a href="#LANGUAGEDEF">5.3 Writing your own language definitions</a></li>
	</ul>
</li>
<li><a href="#CHANGELOG">Changelog</a></li>
</ul>
<hr>

<h1 id="SECTION0">1. Configuring TeXstudio</h1>
<p>Before using TeXstudio, you should configure the editor and latex related commands via the "Configure TeXstudio" command in the "Options" menu ("Preferences" under Mac OS X). Note that there are two levels of detail. More advanced or less often used options are only visible if you toggle "Show advanced options" in the lower left corner.</p>
<h2 id="SECTION01">1.1 Configuring the editor</h2>
<p>
You may change the default encoding for new files ("Configure TeXstudio" -> "Editor" -> "Editor Font Encoding") if you don't want utf8 as encoding. Don't forget to set the same encoding in the preamble of your documents. (e.g. <code>\usepackage[utf8]{inputenc}</code>, if you use utf-8).<br>
TeXstudio can auto detect utf-8 and latin1 encoded files, but if you use a different encoding in your existing documents you have to specify it in the configuration dialog before opening them. (and then you also have to disable the auto detection)
</p>
<ul>
<li>"Folding" toggles the editors code-folding capability (hide sections of the text).
<li>The selection box "Indentation mode" lets you select, whether indented lines are followed by lines of the same indentation after pressing Enter or letting TeXstudio do automatic indentation.
</ul>
<p><IMG src="configure_editor.png" border="1" alt="Configure Editor"></p>
<h2 id="SECTION02">1.2 Configuring the latex related commands</h2>
<p>LaTeX comes with a number of command line tools to compile and manipulate LaTeX
documents. The commands section defines there location and arguments.</p>
<p>The default settings should work with the recent and standard LaTeX distributions,
but you could have to modify them ("Configure TeXstudio" -> "Commands"). To change
a command, just click on the button at the end of the corresponding line and select
the command in the file browser : TeXstudio will automatically adapt the syntax of
the command.</p>
<p>You can use a number of special characters / character sequences to address the
context of the current document. They are expanded at runtime:
<table>
<tr><th>Special Character</th><th>Expands to</th></tr>
<tr><td><code>%</code></td><td>filename of the root document for of current document without extension</td></tr>
<tr><td><code>@</code></td><td>current line number</td></tr>
<tr><td><code>?</code> followed by further characters</td><td>See the instruction at the bottom of the configuration dialog.</td></tr>
<tr><td><code>[txs-app-dir]</code></td><td>Location of the TeXstudio executable (useful for portable settings)</td></tr>
<tr><td><code>[txs-settings-dir]</code></td><td>Location of the settings file (texstudio.ini)</td></tr>
</table>
<p>The section <a href="#SECTION37">Forward/Inverse search</a> gives some example commands for common viewers.</p>
<p>You can always restore the original settings using the revert button to the right.
</p>
<p><IMG src="configure_commands.png" border="1" alt="Configure Commands"></p>
<h2 id="SECTION02a">1.3 Configuring the build system</h2>
<p>TeXstudio provides general commands for translating latex.<br>
The default settings use "pdflatex" and the internal pdf viewer. Other commands and viewer can be selected as well as a different bibliography translator.<br>
The "embedded pdf viewer" does not open a new window for viewing the pdf document but presents it directly next to the text in the editor.<br>
A useful alternative might be using the "latexmk" as compile command (if the command is installed on your system), as it handles dependencies with biblatex and index very well.<br>
The advanced options allows finer customization which is in general not necessary.<br>
</p>
<p><IMG src="configure_build.png" border="1" alt="Configure Build System"></p>
<p>User commands can be defined here by "adding" them. Each user command has a name with a pattern <code>&lt;command id&gt;:&lt;display name&gt;</code>, e.g. <code>user0:User Command 0</code>. The command id has to be unique and must not contain spaces. In <a href="#SECTION02a1">advanced mode</a>, you can reference it using <code>txs:///"&lt;command id&gt;</code>. The display name will be shown in the tools menu. The user commands can be activated either by short cut (alt+shift+F%n) or by the tools menu (Tools/User).<br>
User commands can either consist of a combination of known commands by selecting them from a list of available commands. This is triggered by clicking the spanner-symbol.<br>
Alternatively a command can be directly selected through the file system.</p>
<p><IMG src="doc21.png" border="1" alt="Configure user commands from known commands"></p>

<h2 id="SECTION02a1">1.3.1 Advanced configuration of the build system</h2>

<p>If you enable the advanced options, you can configure the build system in more detail.

<p>Every txs-command is a list of external programs/latex-commands and other txs-commands to call. An external program can be called with its usual command line, while a txs-command with id "foobar" is called by txs:///foobar. <br>
The commands in the list are separated by |, which is just a separator (i.e. it will <i>not</i> pass the stdout from one program to the stdin of the next).

<p>Note: Use command lists only for the meta and user commands listed at <code>Options -> Build</code>. Do not use then at <code>Options -> Commands</code>. The latter should just be single commands
(i.e. do not use | there). While it's currently working in some cases, generally we do not guarantee this behavior. It can have surprising side effects such abortion of compilation in some cases. Also, the use of | at <code>Commands</code> may be prohibited completely without further notice in the future.</p>

<p>Each of these txs-command has a unique id, which is shown as tooltip of the displayed name for "normal" commands and in the edit box for user commands. Some important commands are usual: txs:///quick (Build & View, the old quickbuild), txs:///compile (Default compiler), txs:///view (Default viewer), txs:///latex (latex), txs:///pdflatex (pdflatex), txs:///view-pdf (Default Pdf Viewer), txs:///view-pdf-external (External pdf viewer).

<p>For example, in a typical build configuration you might call txs:///quick by pressing F1, which calls txs:///compile, which first calls txs:///pdflatex that calls the actual pdflatey, and then calls txs:///view, which calls txs:///view-pdf, which calls txs:///view-pdf-internal, which displays the pdf.

<p>There is  no difference between commands defined as command on the command config page, commands defined as build on the build config page, or commands defined as user commands. They are just separated in the GUI to simplify the interface.<br>
This also means that you can change every command as you want, ignoring its old definition (you could even change its id, when editing the ini file.).

<p>There are however three always defined internal commands, which can only be called and not modified:<br><br>

<table>
<tr><td>txs:///internal-pdf-viewer</td><td>Opens the internal viewer for the current document</td></tr>
<tr><td>txs:///view-log</td><td>Views the log file for the current document</td></tr>
<tr><td>txs:///conditionally-recompile-bibliography</td><td>Checks if the bib files have been modified, and calls txs:///recompile-bibliography, iff that is the case</td></tr>
</table>

<p>The internal pdf viewer  also accepts the following options (txs:///internal-pdf-viewer) to modify its behaviour:<br><br>

<table>
<tr><td>--embedded</td><td>Opens the viewer embedded</td></tr>
<tr><td>--windowed</td><td>Opens the viewer windowed  (default if no option is given)</td></tr>
<tr><td>--close-(all|windowed|embedded)</td><td>Close all open viewers, or just viewers of a specific kind</td></tr>
<tr><td>--preserve-existing</td><td>Does not change any existing viewers (i.e. always opens a new one)</td></tr>
<tr><td>--preserve-(embedded|windowed)</td><td>Does not change any existing embedded/windowed viewers</td></tr>
<tr><td>--preserve-duplicates</td><td>Only opens the pdf in the first opened viewer</td></tr>
<tr><td>--(no-)auto-close</td><td>Determines whether the viewer should be closed, when the corresponding tex file is closed (default: auto-close iff embedded)</td></tr>
<tr><td>--(no-)focus</td><td>Determines whether the viewer should be focused (default: focus iff windowed)</td></tr>
<tr><td>--(no-)foreground</td><td>Determines whether the viewer should be brought to front (default: foreground)</td></tr>
<tr><td>filename</td><td>Determines the file to open. Like in other commands, <a href="#SECTION02">file patterns</a> are supported. If this parameter is not provided, TXS uses <code>"?am.pdf"</code>, i.e. the absolute path of the main file. If the parameter is not an absolute filename, it is searched for in the directory of the main file as well as in <code>Options -> Build -> Build Options -> Additional Search Paths -> PDF Files</code></td></tr>
</table>

<p>It is also possible to modify the arguments of called subcommands with argument modifiers or  by adding a new argument . These modifiers are passed through called lists, so it will always change the arguments of the finally called program, even if the directly called subcommand is just a wrapper around another command:<br><br>

<table>
<tr><td>txs:///foobar --xyz</td><td>This will add the xyz option</td></tr>
<tr><td>txs:///foobar[--xyz=123]</td><td>This will change the value of the xyz option to 123 (i.e. removing any xyz option defined in foobar)</td></tr>
<tr><td>txs:///foobar{--xyz=123}</td><td>This will remove --xyz=123 from the foobar command line, ignoring xyz options with other values<td></td></tr>
<tr><td>txs:///foobar{--xyz}</td><td>This will remove any --xyz option from the foobar command line, regardless of its value</td></tr>
<tr><td>txs:///foobar{}</td><td>This will remove all options from the foobar command line, leaving only the name of the executable</td></tr>

</table>

<p>
Finally, there are also hidden options, which can only be changed by modifying the ini-file: Tools/Kind/LaTeX, Tools/Kind/Rerunnable, Tools/Kind/Pdf, Tools/Kind/Stdout, Tools/Kind/Viewer, which give a list of commands that are treated as latex compiler (e.g. show the log afterwards), rerunnable (repeat command call, if there are warnings), pdf generators (e.g. pdflatex), commands that prints to stdout (e.g. bibtex), and viewers (e.g. only open once).
</p>
<h2 id="SECTION02a2">1.3.2 Details of the execution environment</h2>
<h3>Environment Variables</h3>
<p>The environment variables available within the execution are the same as the ones that are available in the context in which TeXstudio was started.
In particular this is true for the PATH. On Linux/OS X the PATH may depend on the way you started TeXstudio. Programs started from the GUI may have a different PATH
setting than programs started from a shell (because some variables may only defined in the context of a shell (e.g. via ~/.bashrc).
</p>
<p>
By default, TeXstudio parses environment variables in your commands. The syntax is adapted to the according operating system. A variable MYVAR would be written as <code>%MYVAR%</code> on
Windows and <code>$MYVAR</code> on Linux and OS X. Windows environment variables are case-insensitive, whereas they are case-sensitive on Linux and OS X. Parsing of environment variables
can be deactivated in the Build section of the options.
</p>
<h3>Working Directory</h3>
<p>
The working directory is set to the path of root document.
</p>
<h3>Shell Functionality</h3>
<p>
All commands specified in the configuration (i.e. Commands and User Commands) are executed directly. There is no shell involved. So most shell functionality does not work.
</p>
<h4>Output Redirection</h4>
<p>TeXstudio provides limited output redirection capabilities. You can only output to the message panel (<code>&gt; txs:///messages</code>) or suppress output (<code>&gt; /dev/null</code>). The default setting depends on the command. The same targets are allowed for stderr: <code>2&gt; txs:///messages</code>, <code>2&gt; /dev/null</code>. Additionally, you can redirect to the same target as stdout by using <code>2&gt;&1</code>.</p>
<p>A typical usecase would be to suppress all output of a command: <code>&gt;/dev/null 2&gt;&1</code></p>
<p>Note: Instead of the Linux/Unix notation <code>&gt; /dev/null</code>, you may alternatively use the Windows notation <code>&gt; nul</code>. Because these commands are directly interpreted by TXS, both variants work on all operating systems.</p>


<h4>Using other shell functionality</h4>
<p>If you need shell functionality, you have to explicitly run a shell. You can either do this directly in the user command:</p>
<pre>
sh -c "/path/to/testscript foo > bar"
</pre>
<p>or on Windows:</p>
<pre>
cmd /C "/path/to/testscript.bat foo > bar"
</pre>
<p>Alternatively, you can call a wrapper script in the user command</p>
<pre>/path/to/wrapperscript foo bar</pre>
<p>and do the actual work inside the wrapper script:</p>
<pre>
#!/bin/sh
# I am wrapperscript
/path/to/testscript $1 > $2
</pre>

<h2 id="SECTION030">1.4 Configuring some general issues</h2>
<p>This panel allows the setting of some general aspects.</p>
<ul>
<li>The "style" and "color scheme" of TeXstudio can be selected. The modern variant is closer to texmaker 1.9.
<li>The symbol list can either appear "tabbed" (old behaviour, tabbed activated) or can have small symbol tabs besides the symbol lists which leaves more room for the symbols.
<li>Also the log viewer can appear tabbed which allows faster change between error table, log view and previewer ...
<li>The language of the menus can be changed directly to ignore system settings.
</ul>
<p><IMG src="configure_general.png" border="1" alt="Configure General"></p>
<h2 id="SECTION03">1.4.1 Configuring the spell checker</h2>
<p>
TeXstudio offers an integrated spellchecker which can be used either via a dialog or directly while typing. All text outside of LaTeX commands is checked. Additionally, text in options of LaTeX commands is also checked. TeXstudio determines if an option contains natural text and thus should be spell checked by looking up its definition in the completion word lists. For more information on completion word lists see the section on <a href="#SECTION040">completion</a> and the <a href="#CWLDESCRIPTION">description of the cwl format</a>.</p>
<p>The spell checker uses the Hunspell dictionary format, which is widely used, e.g. in OpenOffice, LibreOffice and Firefox. The each dictionary consists of two files (<code>.dic</code> and <code>.aff</code>). French, British and German dictionaries are distributed with TeXstudio. You can add additional dictionaries yourself by placting them in the dictionary path. A particularly convenient way to get additional dictionaries is downloading a dictionary extension of <A href="http://extensions.openoffice.org/" target="_blank">http://wiki.services.openoffice.org/wiki/Dictionaries</A> or <a href="https://extensions.libreoffice.org/extensions?getCategories=Dictionary&getCompatibility=any">LibreOffice</a> and importing them using the button <i>Import Dictionary</i> in the options.</p>
<p>You can specify one or more search paths for the dictionaries in the options. Multiple paths need to be separated by semicolon. With the paths you can use the special strings <code>[txs-app-dir]</code> and <code>[txs-settings-dir]</code>. These are expanded to the path of the executable and the config file (<code>texstudio.ini</code>) respectively. This expansion is particularly useful if you use a portable version on a USB stick in which the actual location of the program may depend on the computer you are using.</p>
<p><IMG src="spellcheck_options.png" border="1" alt="Spellcheck Options"></p>
<p>To make life easy TeXstudio lets you choose a preferred language for the spell checker. However, if you frequently work with files in different languages you may want to override the default behavior. This can be done in two ways. First you can specify the language of the file via the language menu in the status line. This setting will be lost as soon as the file is closed. To permanently save the language of the file TeXstudio supports a special "magic comment" <code>% !TeX spellcheck = de_DE</code>. If this comment is present in a file, its language is automatically set when the file is loaded.
<p><IMG src="spellcheck_menu.png" border="1" alt="Spellcheck Menu"></p>

<p>Please note: spell checking with Ctrl+Shift+F7 starts at the cursor position and not at the beginning of the document.</p>
<p>If the interactive spell checker is enabled (default), any incorrectly spelled word is underlined with a red wave. Right-click on the word to open a menu with a list of possible corrections. In this context menu you can also add the word to the ignore list. If your dictionary is very large (> 5MB), opening the context menu and showing possible suggestions can take some seconds. If you don't need the suggestion, you can press shift while right clicking and don't have to wait.</p>
<p>Since the internal structure of the dictionaries is complex (e.g. contains rules how to generate a word with in different inflections) it is not possible to simply add words to the dictionary. Instead if a word is missing in the dictionary, you can add it to an ignore list, so that the spell checker won't complain about it. The ignore list is normally saved in the same directory as the dictionary. It's a plain text file with the extension .ign. If this isn't possible (e.g. missing access rights) the list is stored in the user configuration directory.
</p>
<h2 id="SECTION04">1.4.2 Configuring the thesaurus</h2>
<p>
The thesaurus uses OpenOffice.org 2.x databases. Only GPL French and US-English and German databases are distributed with TeXstudio.<br>
Users can download others databases here : <A href="http://wiki.services.openoffice.org/wiki/Dictionaries" target="_blank">http://wiki.services.openoffice.org/wiki/Dictionaries</A><br>
</p>
<h2 id="SECTION041">1.4.3 Configuring the latex syntax checker</h2>
<p>The latex syntax checker takes the list of possible completion commands to determine if a command is correct.
Furthermore the completion list contains partially additional information to determine in which context a command is valid, whether it is valid only in math-mode or only in tabular-mode.<br></p>
<h2 id="SECTION044">1.4.4 Configuring the grammar checker</h2>
<p>The grammar checker is based on the standard http API of <a href="http://www.languagetool.org/">LanguageTool</a>, and requires a separate installation of LanguageTool and java.

<p>Once LanguageTool is installed, you can try it by starting the LanguageTool standalone application, and start TeXstudio afterward.  LanguageTool then creates  a locally running server at the address http://localhost:8081/ and TeXstudio automatically connects to it at startup. When the connection is established, all typed paragraphs are send to LT and after a short delay the possible grammar errors are highlighted.

<p>To automatically start LanguageTool with TeXstudio, you need to enter the path to LT jar in the grammar page of the config dialog. If the java executable is not in the default PATH, you also need to set the path to it there.

<p>In the advanced config mode, you can also mark certain LT rules as "special" whose matches will then be highlighted in a different/customizable way. This can be useful to do a stylistic analysis, e.g. by creating a own rule in LT highlighting all verbs or all adverbs.

<p>Independent from LanguageTool, TeXstudio also checks for repeated and bad (imprecise/slang) words. The repetition check looks several words behind and marks repetition of short words in the immediate vicinity and repetition of long words up to 10 words before. These distances and lengths can be changed in the advanced grammar config page.


<h2 id="SECTION040">1.5 Configuring the autocompletion</h2>
<p>
TeXstudio has taken up completion word lists from kile which extended the number of known commands for completion considerably.
TeXstudio understands the use of \documentclass and \usepackage in order to select valid lists of commands for completion as well as syntax checking.
However TeXstudio allows one to select the additional word lists under
"Configure TeXstudio" -> "Editor" -> "". The names of the word lists corresponds to the package for which they are made. The list latex.cwl contains the standard latex commands. <br>
Concerning auto completion, TeXstudio allows one to adapt the behaviour to your liking.
The following options are available:</p>
<ul>
<li>Completion enabled: self explanatory
<li>Case sensitive: lets you complete e.g. \Large from \la ...
<li>in first character: ?
<li>Auto Complete Common Prefix: if only one item is in the list or all items in the completion list share common starting characters, the common characters are directly inserted, like pressing the key Tab.
<li>Complete selected text when non-word character is pressed: when in completion mode, pressing a non-word character like space, leads to accepting the selected word. This may speed up typing.
<li>Enable ToolTip-Help: show tool tips on selected latex commands in the completion list.
<li>Use Placeholders: if the completed commands have options which need to be filled out, placeholders are put at these positions and they can be jumped to by using Ctrl+Right/Ctrl+Left.
</ul>
<p>If your favorite package is not yet present for completion (and syntax checking), you can provide a list of your own by placing a file "packagename.cwl" in the <a href="https://github.com/texstudio-org/texstudio/wiki/Frequently-Asked-Questions#where-are-the-settings-stored">config directory</a>. This directory is placed in ~/.config/texstudio under Linux and usually "c:\Documents and Settings/User/AppData/Roaming/texstudio" under Windows. Basically the file contains a list of valid commands. A description of the exact format and an example are given in the <a href="#CWLDESCRIPTION">appendix</a>.
</p>

<p><IMG src="configure_completion.png" border="1" alt="Configure Completion"></p>
<h2 id="SECTION05">1.6 Configuring shortcuts</h2>
<p>
Shortcuts can be changed by double clicking on "Current Shortcut" or "Additional Shortcut".
A shortcut can be selected from the drop down list or put in as text directly.
A shortcut can be assigned a multiple keystroke combinations, for example <code>CTRL+M,CTRL+A</code> (either upper or lower case is allowed, but the comma is important).
If a shortcut should be set to default value or removed completely, the items "&lt;default&gt;" or "&lt;none&gt;" at the top of the list can be selected respectively.
</p>
<p>
A rough overview of the available (default) keyboard shortcuts can be found in <a href="#SHORTCUTS">Section 4.12</a>.
</p>
<p><IMG src="configure_shortcuts.png" border="1" alt="Configure Shortcuts"></p>
<h2 id="SECTION06">1.7 Configuring the Latex/Math-Menu (Advanced option)</h2>
<p>The Math/Latex-Menu can be adapted to user likings.
For this menu items can be renamed and a new Latex-Code can be placed. The appropriate item can be be directly edited by doubleclicking on them.
</p>
<p><IMG src="configure_customizeMenu.png" border="1" alt="Customize Menu"></p>
<h2 id="SECTION07">1.8 Configuring the Custom Toolbar (Advanced option)</h2>
<p>One Custom Toolbar is present in TMX. This toolbar can be filled with actions from the Latex-, Math- and User-Menu.
Since many of those item don't have icons, user icons can be loaded as well. This is achieved by applying "load other icon" from the context menu on a item in the custom toolbar list in the configure dialog.
</p>
<p><IMG src="configure_customToolbar.png" border="1" alt="Customize Toolbars"></p>
<h2 id="SECTION08">1.9 Configuring SVN support</h2>
<p>To supports SVN (subversion) for document versioning. To make use of it, the SVN commandline tools need to be installed.
Linux and Mac OSX normally provide already SVN tools, for Windows, the installation of "SlikSVN" is recommended.
</p>
<p>The complete path to the command "svn" and "svnadmin" need to be adjusted in the aprioriate field of the Commands page in the options.
On the SVN page you can can choose the degree of automation (see below) WSVN, see below.
</p>
<p>Note: You cannot checkout a repository via TeXstudio. Just use the normal tools for this (either SVN checkout on the command line or the GUI of your choice).
Once you have a working copy, TeXstudio can operate on it.
</p>
<p>
"Automatically check in after save" allows TeXstudio to perform an SVN check in after every save of a document, thus providing a very complete history of the creation of a document.
Since text documents are rather small compared to disk spaces, size of the SVN database should not be a problem.
In addition newly saved files (save as) are automatically added to SVN control,provided that the directory is already under SVN control.
If that is not the case, TeXstudio searches in "SVN Directory Search Depth" directory above the current diorectory for a SVN controlled directory to which the subdirectories and the TeX-Document will be added.
If no appropriate directory is found, a repository is automatically generated in a directory called "./repo" and the document is added.
Thus the user does not need to look up the necessary commands to set up a repository. This functionality is only activated when "Auto checkin in" is enabled !
</p>
<p>
With "User SVN revisions to undo before last save" TeXstudio will perform undo as usually, but if there are no further undoable commands in the internal storage, the document will be changed to the previous version in SVN history.
Further undo commands allows one to back further to older revisions, whereas a redo goes forward to more recent versions.
This is a more interactive approach than choosing SVN revisions directly via a menu command, see <a href="#SECTION33a">section 4.4</a>.
</p>
<p><IMG src="configure_svn.png" border="1" alt="Configure SVN"></p>
<h1 id="SECTION1">2. Editing a TeX document</h1>
<h2 id="SECTION11">2.1 Usual commands</h2>
<p>The standard commands (cut, copy, find...) can be launched via the "Edit" menu and the "Edit" tool bar.</p>
<p><IMG src="doc1.png" border="1" alt="Standard commands"></p>

<h2 id="SECTION12">2.2 Creating a new document</h2>

<p>There are two different ways to create a new document that are described in the following subsections:</p>

<h2 id="SECTION12a">2.2.1 Setting the preamble of a TeX document</h2>
<p>To define the preamble of your document, you can use the "Quick start" wizard ("Wizard" menu).</p>
<p><IMG src="doc2.png" border="1" alt="Quick Start"></p>
<p>This dialog allows you to set the main features of your document (class, paper size, encoding...).<br>Note : You can add other options by clicking the "+" buttons. All your settings are recorded.</p>
<p>You can also type your own preamble model in the editor : with the "Copy/paste" or "Save As" commands, you can use it for a new document.</p>
<h2 id="SECTION12b">2.2.2 Using Templates to start a new document</h2>
<p>For new documents, templates can be used by using the command "File/New from template".
A dialogue gives a selection of templates.</p>
<p><IMG src="template.png" border="1" alt="Templates"></p>
<p>You can either create a new editor document from the template or create it as file(s) on disk and open these in the editor. The former option is not available for multi-file templates.</p>
<p>New templates can be created by using the command "File/Make Template" on a opened document which you like to have has a template. Note that this dialog currently does not support the full capabilities of the template system. In particular you cannot supply a preview image or create a multi-file template with it. You'll have to do this manually (see the <a href="#SECTION12ba">template format</a>).</p>
<p>User added templates can be edited or deleted by using the context menu in the template selection dialogue.
Built-in templates can not be changed.</p>
<p>User templates are saved in the <code>/templates/user/</code> subdirectory of the config directory.</p>
<h3 id="SECTION12ba">2.2.2.1 The Template Format</h3>
<p>In its simplest form, a template is only a .tex file. Multi-file templates can be created by packaging all .tex files in a zip archive. Optionally, meta data can be stored in JSON format in a separate file with the same name, but extension ".json" instead of ".tex" or ".zip". Currently the following entries are supported in the meta data:</p>
<pre>
{
"Name"        : "Book",
"Author"      : "TXS built-in",
"Date"        : "04.01.2013",
"Version"     : "1.1",
"Description" : "Default LaTeX class for books using separate files for each chapter.",
"License"     : "Public Domain",
"FilesToOpen" : "./TeX_files/chapter01.tex;main.tex"
}
</pre>
<p>FilesToOpen only has an effect for mutli-file documents. You may add a preview image next to the template file. Again, it must have the same name, but extension ".png".</p>

<h2 id="SECTION13">2.3 Structure of a document</h2>
<p>To define a new part (section,subsection...) in your document with TeXstudio, just use this combo box button in the tool bar :</p>
<p><IMG src="doc3.png" border="1" alt="Sectioning"></p>


<h2 id="SECTION14">2.4 Browsing your document</h2>
<p>The "Structure View" (left panel) lets you quickly reach any part of your document. All you need to do is to click on any item (label, section...) and you will be taken to the beginning of the corresponding area in the editor. The mechanism for jumping to a line does not anymore only consider line numbers but really remembers text lines. Thus adding and removing lines will not lead to jumps to wrong locations.</p>
<p>A grey background shows the present cursor position in the text in the structure view as well. A greenish background denotes sections which are in the appendix.</p>
<p><IMG src="doc5.png" border="1" alt="Appendix"></p>
<p>The "Structure View" is automatically updated as you type. You can also use the "Refresh Structure" (menu "Idefix") command at any moment.</p>
<p>The structure view shows labels, sections, includes and beamer blocks and todos.</p>
<p>There are two kind of todos that will be listed a) todos from a todo-like command, e.g. \todo{} from the package todonotes. b) todo-comments: This is a comment with a "% TODO" or "%todo". You can adapt the regular expression for other comments to be marked as todo-comment in <em>options/advanced editor/Regular Expression for TODO comment</em>, e.g "%\s?[A-Z][A-Z_\-]+" for any comment starting with at least two capital letter only comment.</p>
<p>
The structure view also offers a context menu which allows one to copy/cut all text which belongs to a section (including subsection) and paste it before or after a section.
Section can be indented/unindented which means that the hierarchy level is changed by one, i.e. \section is changed to \subsection, and all subsections are treated accordingly

</p>
<p>For each file, three bookmarks can be used to speed up navigation : just click on a line number to add or remove a bookmark. When you have already defined three bookmarks, you must remove one of them to add a new bookmark. To jump to the line corresponding to a bookmark in the editor, just click on the buttons in the status bar.</p>
<p><IMG src="doc20.png" border="1" alt="Bookmark"></p>
<h2 id="SECTION15">2.5 Formatting your text</h2>
<p>You can quickly set the format of a part of your text with this tool bar :</p>
<p><IMG src="doc6.png" border="1" alt="Format Toolbar"></p>
<p><b>Additional option:</b> a selected text can be directly framed by certain environments. Example: while clicking on the button "Bold" after having selected the word "Hello" , you will obtain the code: \textbf{Hello}.<br>This option is available for all the environments indicated by "[selection]" in the "LaTeX" menu.</p>
<h3>Capitalisation</h3>
<p>The menu "Edit" -> "Text Operations" contains a few methods for changing the capitalization of selected text:</p>
<ul>
<li>To Lowercase</li>
<li>To Uppercase</li>
<li>To Titlecase (strict)</li>
<li>To Titlecase (smart)</li>
</ul>
<p>Both variants of "To Titlecase" leave small words like a, the, of etc. in lowercase. Additionally, "To Titlecase (smart)" does not convert any words containing capital letters, assuming they are acronymes which require a fixed capitalization (e.g. "TeXstudio").</p>
<h3>Escaping reserved characters</h3>
<p>If you have text containing reserved TeX characters and want the text to appear literally in your document, you have to escape the reserved characters to prevent LaTeX from interpreting them. The following functions take care of that (Menu: Idefix)</p>
<ul>
<li>Paste to LaTeX: Takes the text from the clipboard and escapes reserved characters prior to pasting into the editor.</li>
<li>Convert to LaTeX: Escapes the reserved characters in the current selection.</li>
</ul>
<p>For example: "Less than 10% of computer users know the meaning of $PATH." will be converted to "Less than 10\% of computer users know the meaning of \$PATH."</p>
<h2 id="SECTION16">2.6 Spacings</h2>
<p>The usual "spacing" commands are available in the "LaTeX" and "Math" menus.</p>
<h2 id="SECTION17">2.7 Inserting a list</h2>
<p>The usual list environments code can be insert quickly via the "LaTeX-List" menu.<br>Note : the shortcut for the \item command is Ctrl+Shift+I.</p>
<h2 id="SECTION18">2.8 Inserting a table</h2>
<p>With the "Tabular" wizard ("Wizard" menu), the LaTeX code for a tabular environment can be quickly inserted :</p>
<p><IMG src="doc7.png" border="1" alt="Tabular Wizard"></p>
<p>You can set the main features of your table.<br>Note : this dialog allows you to type directly the code in the cells.<br>The corresponding LaTeX code is automatically inserted in the editor.</p>
<h2 id="SECTION18a">2.8.1 Manipulating tables</h2>
<p>TeXstudio provides some commands to ease handling of tables. The commands are located at LaTeX &rarr; Manipulate Table and in the Table toolbar. Please be aware that some unexpected results may arise, if the table constructing commands get too complex.
Following commands are offered:</p>
<ul>
<li>Add Row after the current row</li>
<li>Remove Row: removes the table row in which the cursor </li>
<li>Add Column: add a column in the complete table after current cursor position. If the cursor is positioned at start of line,first column, the column is added as new first column.</li>
<li>Remove Column: remove current column</li>
<li>Add/Remove \hline: add/remove \hline in all rows following the current row. If already a command \hline is present, no second command is placed.</li>
<li>Align Columns: Aligns the column separators (ampersand) by introducing whitespace. The text in the cells is aligned according to the specification in the table header. This helps reading the table source.</li>
<li>Remodel the table after a template. This allows one to force uniform table set-up in a document. Some templates are predefined, more can be added though it needs some programming in java script. This command is only present in the menu (math/tables)</li>
</ul>
<p>TeXstudio also allows block cursors. Press &lt;Ctrl&gt;+&lt;Alt&gt;+&lt;Shift&gt; and drag the cursor with the mouse. The block cursor works like a set of normal cursors. You can copy and paste text as usual. Also you can type in new text, which will be added in every row.</p>
<p><IMG src="block_selection.png" border="1" alt="Block Selection"></p>
<h2 id="SECTION19">2.9 Inserting a "tabbing" environment</h2>
<p>To help you to insert a "tabbing" code, you can use the "Tabbing" wizard ("Wizard" menu) :</p>
<p><IMG src="doc8.png" border="1" alt="Tabbing Wizard"></p>
<h2 id="SECTION110">2.10 Inserting a picture</h2>
<p>To insert a picture in your document, just use the "\includegraphics" command in the "LaTeX" menu. Then, click on the "browser" button in the dialog to select the graphic file.<br>Note : you can insert a "figure" LaTeX environment ("LaTeX - Environments" menu) before inserting the picture.</p>
<p><IMG src="doc9.png" border="1" alt="Figure Environment"></p>
<h2 id="SECTION110a">2.10.1 Inserting a picture using a "wizard"</h2>
<p>Properly inserting figures is a challenge for LaTeX beginners and still quite a bit of text to type for the expert. Therefore TeXstudio offers a wizard for handling graphics insertion code in your document. "Graphics options" defines the optional parameter of <code>\insertgraphics[options]{file}</code>. While the most used width/height attributes can be easily set, alternatively you have full control with the user defined setting.<br>
Place the graphic inside a <code>figure</code> environment if it does not have to be at an exact position in the text. Then LaTeX will determine an optimal position on the page.<br>
By pressing the "Save as default" button the current settings (except file, caption and label) are stored and will hence be used as default when you open the wizard.<br>
The wizard also comes into play when you drag   drop an image file to your document or use copy in explorer and paste in TeXstudio. Together with the adjustable default parameters this makes insertion of new pictures very fast. Furthermore, if you start the wizard while the cursor is on picture code, the wizard is used to manipulate the existing picture settings.</p>
<p><IMG src="wizard_figure.png" border="1" alt="Figure Wizard"></p>
<h2 id="SECTION111">2.11 Cross References and notes</h2>
<p>This toolbox in the toolbar allows you to insert quickly the label, cite, ref, footnote... code.<br>Note : the labels used in your documents are displayed in the "Structure View".</p>
<p><IMG src="doc10.png" border="1" alt="Structure View Labels"></p>
<p><b>Additional option:</b>for the \ref command, a dialog box allows you to select directly the label.</p>
<h2 id="SECTION112">2.12 Inserting math formula</h2>
<p>You can toggle in the "in-line math" environment with the "f(x)" button in the toolbar (shortcut : Ctrl+Alt+M) or with the "Math" menu. The shortcut for the "display math" environment is : Alt+Shift+M.<br> The "Math" toolbar allows you to insert the most currents mathematical forms (frac, sqrt...) like the \left and \right tags.</p>
<p><IMG src="doc11.png" border="1" alt="Math Toolbar"></p>
<p>With the "symbols panels" in the structure view, you can insert the code of 400 mathematical symbols.</p>
<p><IMG src="doc12.png" border="1" alt="Math Symbols Panel"></p>
<p>You can also define the format of your mathematical text via the "Math" menu.<br>For the "array" environments, a wizard (like the "Tabular" wizard) is available in the "Wizard" menu. With this wizard, you can select the environment : array, matrix, pmatrix.... The cells can be directly completed.</p>
<p><IMG src="doc13.png" border="1" alt="Array Wizard"></p>
<h2 id="SECTION113">2.13 Auto Completion</h2>
<p>Whenever you press \  followed by a letter, a list of possible LaTeX tags is shown where you select the right one. If you type additional letters, the list is filtered, so that only the tags starting with the already written text are shown.
If the list contains words which all start with the same letter combination, you can press Tab to complete all common letters. If only one element is present in the list, Tab selects this one to do the completion, like Enter. This behaviour is similar to tab completion in bash shells.
You can also press Ctrl+Space to open this list whenever you want.<br>
If a tag has different options, a short descriptive text is inserted into your text, telling you the meaning of each option. You can press Ctrl+Left, Ctrl+Right to select all positions.<br>
Furthermore normal text can be completed by starting to type a word and pressing Ctrl+Space. All appropriate words in the current document are used as possible suggestions.<br>
If an environment is to be inserted, typing in the beginning of the environment name and pressing Ctrl+Alt+Space gives suggestions for adequate environments which are inserted completely with \begin{env}..\end{env}.<br>
And finally, user tags can be assigned an abbreviation which can also be used with completion. Just type in the start of the abbreviation and start the completion with Ctrl+Space. The abbreviation should show up in the completion list, especially marked with &ldquo;abbreviation (template)&rdquo;.<br>
If you change a command by completing a new command, only the command name is substituted. The same is true for environments, where the environment is changed in the \begin- and \end-command.<br>
<br>
The completer has several operation modes which are shown in the tabs below the command list.<br>
<ul>
<li>Typical: list only typical commands and filter out rather unusual commands.</li>
<li>Most used: list only commands which have already been used in the completer by the user. Is empty if txs has not been used before.</li>
<li>Fuzzy: search the command in a fuzzy way. The command needs to contain all given letters in the same order though with a arbitrary of letters between them. E.g. \bf lists, among others, \<b>b</b>egin{<b>f</b>igure}</li>
<li>All: list all known commands.</li>
</ul>
</p>

<h2 id="SECTION114">2.14 Thesaurus</h2>
<p>TeXstudio has integrated a simple thesaurus. OpenOffice 2.x databases are used for this.
By placing the cursor on a word and activating the thesaurus (Ctrl+Shift+F8 or Edit/Thesaurus), it tries to find synonyms for this word. Please be patient if you start the thesaurus at first time since loading the database just occurs then and can take a few moments.</p>
<p><IMG src="thesaurus.png" border="1" alt="Thesaurus"></p>
<p>The first line to the left contains the word, for which a synonym is searched for.
The list below gives a list of word classes. The can be chosen to reduce the number of suggestions.
The column to the right contains the list of suggested synonyms.
A selected word from this list apears in the first line to the right as proposition for replacement of the text.
This word can be changed manually. It is also used to do further investigations for words and their synonyms which "start with" or "contain" that word. With "lookup" it can be directly used to look for a synonym for that word.</p>
<h2 id="SECTION115">2.15 Special Commands</h2>
<h3>Delete word/command/environment</h3>
<p>With the shortcut Alt+Del, the word under the cursor is deleted.
If it is a command, the command is deleted including opening and closing braces.
E.g. "\textbf{text}" leave "text".
If it is an environment, the enclosing begin/end are removed.</p>
<h3>Rename environment</h3>
<p>If you place the cursor on an environment name or the corresponding begin- or end-command, after a moment a mirror-cursor is activated on the environment name which allows synchronous change of the environment name in the begin- and end-command.
So if you want to change a "\begin{tabular}...\end{tabular}" construction to "\begin{tabularx}...\end{tabularx}", place the text cursor on "tabular", wait for a second and then, after the mirror-cursor appears, change "tabular" to "tabularx".</p>
<h3>Cut Buffer</h3>
<p>If you select something and then start to type in a command and complete it, the selection is put in as first argument.
E.g. you have a "text", select it and start typing "\textbf", command which is completed. The resulting text is "\textbf{text}"</p>
<h1 id="SECTION2">3. Compiling a document</h1>
<h2 id="SECTION22">3.1 Compiling</h2>
<p>The easiest way to compile a document is to use the "Compile" command or the "Build&amp;View" command ("Compile" button - shortcut : F6). You can select the default command via the "Configure TeXstudio" dialog.<br>(You can also launch each command one by one in the "Tools" menu).<br> Note : the "Clean" command in the "Tools menu" allows you to erase the files (dvi, toc, aux...) generated by a LaTeX compilation (except the ps and pdf files).</p>
<p><IMG src="compile_toolbar.png" border="1" alt="compile_toolbar">
<p><b>Warning: all your files must have an extension and you can't compile an "untitled" file or a file with a space in its name</b>.</p>
<h2 id="SECTION23">3.2 The log files</h2>
<p>With the "Quick Build" command, the log file is automatically displayed in the "Messages / Log file" pannel. While clicking on a number in the "Line" column, the cursor is placed on the corresponding line in the editor and the error is displayed. <br>
Remark : a summary of the latex errors and warnings is displayed before the full log file.</p>
<p><IMG src="doc15.png" border="1" alt="doc15"></p>
<p>The "Next Latex Error"and "Previous LaTeX Error" commands allow to get to the errors detected during compilation.</p>
<p>Lines with errors, warnings, bad boxes will be highlighted with red, yellow or blue background and you can jump between them using Ctrl+Up/Down. (Ctrl+Shift for errors only, Ctrl+Alt for warnings only, Alt+Shift for bad boxes only)<br>
A tool tip will show more details of the mistake if you jump to a line (it is also shown if you move the mouse over the mark left from the line numbers).</p>
<h1 id="SECTION3">4. Other features</h1>
<h2 id="SECTION31">4.1 About documents separated in several files</h2>
<p>LaTeX documents may be spread over multiple files. TeXstudio automatically understands parent/child relations of loaded documents. This includes the detection of the root document and knowledge on defined labels and commands.</p>

<h3 id="sec:rootdocument">4.1.1 Root Document</h3>
<p>The root document is the top-most file in a multi-file document. For a single-file document this is the file itself. By default, all calls to LaTeX will be performed on the root document.</p>
<p>TeXstudio automatically detects the root document. If that does not work, you can place a magic comment <code>% !TeX root = root-filename</code> at the top of your included files.</p>
<p>As a last resort, you may set an <i>explicit root document</i> via <code>Options -> Root Document -> Set Current Document As Explicit Root</code>. This setting takes absolute precedence. All the commands of the "Tools" menu will be called on this document (to be more precise, the build system will expand the placeholder <code>%</code> to the root document), no matter which document is active in the editor. Additionally, labels and usercommands which are defined in any open document, can be used for completion in any open document.</p>
<p>In earlier versions, the <i>explicit root document</i> was somewhat misleadingly called <i>master document</i>.</p>

<h3 id="sec:rootdocument">4.1.2 Loaded Documents</h3>
<p>Obviously, TeXstudio can only use information (defined commands, labels, document hirachy, etc.) that it is aware of. We use the information in all opened files, but if a label in a multi-file document is defined in a not-loaded files, TeXstudio does not know about it and will mark it as missing in references. To remedy this, you can just open the corresponding file as well.</p>

<p>More recent versions of TeXstudio have an advanced option <code>Editor -> Automatically load included files</code>. It's disabled by default for performance reasons with older systems. When you enable this option, TeXstudio will automatically load and parse all files of multi-file-documents as soon as one of the files is opened. You may have to set the magic comment <code>% !TeX root = root-filename</code> if you do not have the root document open.
With this option enabled TeXstudio will always know about your complete document and act accordingly when performing highlighting or completion.</p>


<h2 id="SECTION32a">4.2 Syntax Check</h2>
<p>The latex syntax checker takes the list of possible completion commands to determine if a command is correct.
The completion list contains partially additional information to determine in which context a command is valid, whether it is valid only in math-mode or only in tabular-mode.<br>
Furthermore the correctness of tabulars is checked in a little  more detail.
The number of columns is analyzed and checked in the subsequent rows. If more or less columns are given in a row, a warning maker is shown.<br>
</p>
<h2 id="SECTION32">4.3 Bibliography</h2>
<p>For the "bib" files , the "Bibliography" menu enables you to directly insert the entries corresponding to the standard types of document.<br>Note: the optional fields can be automatically deleted with the "Clean" command of the "Bibliography" menu.</p>
<p><IMG src="doc16.png" border="1" alt="Bibliography Menu"></p>
<h2 id="SECTION33a">4.4 SVN Support</h2>
<p>
Apart from the supported SVN features already describes in section 1.8, TeXstudio supports two more commands.
</p>
<p>
"File/chekin" performs an explicit save and check in, with a input dialog which asks for an checkin in message which is stored in the SVN history.
</p>
<p>
"File/Show old Revisions" pops up a dialog, which shows all available revisions. A selection of an older revision leads to instantaneous change of the current document to that older revision.
You can select and copy old parts to transfer them to the most recent version of your document, by copying the parts and then going back to most recent version.
If you start editing that document directly, the dialog is closed and the present text will be your new most recent version though yet unsaved.
</p>
<h2 id="SECTION33">4.5 Personal macros</h2>
<p>TeXstudio allows you to insert your own macros. These macros are defined with the "Macros - Edit Macros" menu.
Macros can consist of simple text which is directly placed into txs. It can also be an "environment" which are automatically extended by begin/end or it can be a java script.
The needed functionality can be selected by checkbox.<br>
The "abbreviation" is a pseudo-command for the latex completer. If the pseudo-command is completed, the macro will be inserted instead. Note that the pseudo-command needs to start with a backslash ("\").<br>
"Trigger" is a regular expression which triggers the inclusion of the macro: When the last written characters match this expression, they are removed and the macro is inserted/executed. (see <a href="#sectionTriggers">below</a> for more details).<br>
Some macros can be directly downloaded from an internet repository. The dialog is started with the button "Browse". For easier data exchange, macros can be im- and exported to a file. If you want to add a macro of your own to that repository, you can hand it in as a feature request on <a href="https://github.com/texstudio-org/texstudio/issues">Github</a>. <br>
Each macro can be assigned a fixed shortcut in the "Shortcut" box.<br>
The list of macros on the left-hand side represents the macro ordering in the macro-menu. It is rearranged with the "up"/"down"/"add"/"remove" buttons or with drag and drop. Folders can be added to sort a larger number of macros sensibly. To move macros into/from folders, only drag and drop works.<br>
The "run script" button directly executes a script in the editor for testing.<br>
<br>
<p><IMG src="doc17.png" border="1" alt="doc17"></p>

<h3 id="sec_textmacros">4.5.1 Text macros</h3>
<p>
Apart from normal text, some special codes are recognized and replaced on insertion.<br>
<ul>
<li>If you write %| somewhere the cursor will be placed at that place in the inserted text. (A second %| will select everything between them).</li>
<li>Write %&lt;something%&gt; to mark it as placeholder which is highlighted in the text and can be selected by Ctrl+Left/Right. <br>Additional properties of the placeholder can be set after a %:, e.g. %&lt;something%:persistent,id:123,mirror%&gt;. The available properties are:
<ul>
<li>select: The placeholder will be selected (similar to %|)</li>
<li>multiline: The placeholder is used for multiline text. If a macro insertion replaces an existing text, the replaced text is again inserted into a placeholder in the macro. If the original text spans more than one line, it will be inserted into a placeholder with the multiline property. Otherwise in a placeholder with the select-property.</li>
<li>persistent: The placeholder is not automatically removed, when its text is changed in the editor</li>
<li>mirror: The placeholder is a mirror of another placeholder in the macro and thus will always have the same content as the original placeholder. You should set an id, so it knows which placeholders are connected</li>
<li>id:123: The id of the placeholder</li>
<li>columnShift:-12: The placeholder is not placed where the %&lt; markers are, but some columns to the left of it</li>
<li>translatable: The text of the placeholder should be added to translations (only applicable to macros that are known during the compilation of texstudio).</li>
</ul></li>
<li>The option %(<i>filefilter</i>%) will be replaced by a filename which is asked for in a file dialog. The file filter is the standard Qt-Filefilterformat.
For example "Images (*.png *.xpm *.jpg);;Text files (*.txt);;XML files (*.xml)", see also <a href="http://doc.trolltech.com/4.6/qfiledialog.html#getOpenFileName">Qt-Doc</a></li>
</ul>
</p>

<h3 id="SECTION33b">4.5.2 Environment macros</h3>
<p>The text will be used as environment-name, thus "%environment" will be inserted as:<br>
\begin{environment }<br>
<br>
\end{environment }<br>
<br>
Note: texstudio needs that the env-name starts with "%", though that character is not placed on insertion.</p>
<h3 id="JAVASCRIPT-MACROS">4.5.3 Script Macros</h3>
<p>Instead of using code snippets, you can also make use of scripting with QtScript. QtScript is an application scripting language based on <a href="http://doc.qt.io/qt-5/ecmascript.html">ECMAScript</a>. Since QtScript and JavaScript are both an implementation of ECMAScript, you'll pick up QtScript easily if you are familiar with JavaScript.</p>

<p>Put "%SCRIPT" in the first line to declare a macro as a script. Here are the objects that provide the interface to the TeXstudio internals:</p>
<ul>
<li>"editor" allows some top level operations like searching/save/load. in the current document</li>
<li>"cursor" gives access to cursor operations like moving, inserting and deleting texts.</li>
<li>"fileChooser" gives access to the filechooser dialog, a very simple file selection dialog</li>
<li>"app" to access application wide things like the clipboard or the menus</li>
</ul>
<p>The following table gives an overview on the possible commands.</p>
<table class="scripting_help">
  <tr>
    <th>Command</th>
    <th>Description</th>
  </tr>
  <tr>
  <th colspan=2>Global scope</th>
  </tr>
  <tr>
  	<td> alert(str), information(str), warning(str) or critical(str) </td>
	<td> shows str in a messagebox with a certain icon</td>
  </tr>
  <tr>
  	<td> confirm(str) or confirmWarning(str)</td>
	<td> shows str as a yes/no question in a messagebox </td>
  </tr>
  <tr>
  	<td> debug(str) </td>
	<td> prints str to stdout </td>
  </tr>
  <tr><td> writeFile(name, value) </td>	<td> Writes value to file name (requires write privileges) </td></tr>
  <tr><td> readFile(name) </td>	<td> Reads the entire file name (requires read privileges) </td></tr>
  <tr><td> system(cmd, workingDirectory="") </td>	<td> Calls cmd and returns a ProcessX object which has this methodes:
    <ul>
    <li>waitForFinished: Wait until the process is finished</li>
    <li>readAllStandardOutputStr: Returns the stdout</li>
    <li>readAllStandardErrorStr: Returns the stderr</li>
    <li>exitCode: The exit code</li>
    <li>exitStatus: The qt exit status</li>
    <li>terminate or kill: Stops the process</li>
    </ul>
	If workingDirectory is not set, the working directory will be inherited from the TeXstudio executable.
  </td></tr>
  <tr><td> setGlobal(name, value) </td>	<td> Sets a temporary, global variable </td></tr>
  <tr><td> getGlobal(name) </td>	<td> Reads a global variable </td></tr>
  <tr><td> hasGlobal(name) </td>	<td> Checks for the existence of a global variable </td></tr>
  <tr><td> setPersistent(name, value) </td>	<td> Sets a global configuration variable. (can change the values of the ini file, requires write privileges) </td></tr>
  <tr><td> getPersistent(name) </td>	<td> Reads a global configuration variable. (can read all values of the ini file, requires read privileges) </td></tr>
  <tr><td> hasPersistent(name) </td>	<td> Checks if a global configuration variable exists. (requires read privileges) </td></tr>

  <tr><td> hasReadPrivileges() </td>	<td> Checks if the script has read privileges </td></tr>
  <tr><td> hasWritePrivileges() </td>	<td> Checks if the script has write privileges </td></tr>
  <tr><td> registerAsBackgroundScript([id]) </td>	<td> Allows the script to run in the background (necessary iff the script should handle events/signals) </td></tr>
  <tr><td>triggerMatches </td>	<td> Matches of the regular trigger expression, if the script was called by an editor <a href="#sectionTriggers"> trigger</a>.</td></tr>
  <tr><td> triggerId </td>	<td> Numeric id of the trigger, if the script was called by an event <a href="#sectionTriggers"> trigger</a>. </td></tr>
  <tr><td> include(script) </td>	<td> Includes another script. Can be a filename or the name of a macro. </td></tr>
  <tr><td> pdfs </td>	<td> List of all open, internal pdf viewers . </td></tr>

  <tr><th colspan=2>Editor object</th></tr>
  <tr>
  	<td> editor.search(searchFor, [options], [scope], [callback]) </td>
	<td> Searches something in the editor.
	     <ul>
	     <li>searchFor is the text which is searched. It can be either a string (e.g. "..") or a regexp (e.g. /[.]{2}/). </li>
	     <li>options is a string and a combination of "i", "g", "w" to specify a case-<em>i</em>nsensitive search, a <em>g</em>lobal search (continue after the first match) or a whole-<em>w</em>ord-only search. </li>
	     <li>scope is a cursor constraining the search scope (see editor.document().cursor).</li>
	     <li>callback is a function which is called for every match. A cursor describing the position of the match is passed as first argument.</li>
	  </ul>
	  All arguments except searchFor are optional, and the order may be changed (which may not be future compatible). The function returns the number of found matches.
	  </td>
  </tr>
  <tr>
  	<td> editor.replace(searchFor, [options], [scope], [replaceWith]) </td>
  	<td> This function searches and replaces something in the editor. It behaves like editor.search apart from the replaceWith argument which can be a simple string or a callback function. If it is a function the return value of replaceWith is used to replace the match described by the cursor passed to replaceWith.  </td>
  </tr>
  <tr>
  	<td> editor.replaceSelectedText(newText, [options]) </td>
  	<td>  This function replaces the current selections with newText or inserts newText, if nothing is selected. <br>
  	     If newText is a function, it will be called with the selected text and corresponding cursor, and the return value will be the newText.<br>
  	     It is recommended to use this function for all text replacements/insertions, since it is the easiest way to handle multiple cursors/block selections correctly. Though it is only available in txs >= 2.8.5.<br><br>

  	    Options is an object that can have the following properties:
  	    <ul>
  	    <li><code>{"noEmpty": true}</code>    only replaces; does not insert anything if the selection is empty</li>
  	    <li><code>{"onlyEmpty": true}</code>  only inserts at the cursor position; does not change non empty selected text</li>
  	    <li><code>{"append": true}</code>     appends newText to the current selection, does not remove the old text</li>
  	    <li><code>{"prepend": true}</code>    prepends newText to the current selection, does not remove the old text</li>
  	    <li><code>{"macro": true}</code>      Treats newText as normal macro text, e.g. inserting %&lt; %&gt; placeholders </li>
  	    </ul><br>
  	    Examples:<br>
  	    <code>editor.replaceSelectedText("world", {"append": true} )</code> Appends "world" to the current selections.<br>
  	    <code>editor.replaceSelectedText(function(s){return s.toUpperCase();})</code> Converts the current selection to uppercase.  </td>
  </tr>
  <tr>
    <td>editor.insertSnippet(text);</td>
    <td> Inserts a text snippet into the editor. For a list of extended features and syntax see <a href="#sec_textmacros">Text Macros</a>.</td>
  </tr>
  <tr>
    <td> editor.undo();</td>
    <td>undo last command in editor</td>
  </tr>
  <tr>
    <td> editor.redo();</td>
    <td> redo last command in editor</td>
  </tr>
  <tr>
    <td> editor.cut();</td>
    <td> cut selection to clipboard</td>
  </tr>
  <tr>
    <td> editor.copy();</td>
    <td> copy selection to clipboard</td>
  </tr>
  <tr>
    <td> editor.paste();</td>
    <td> paste clipboard contents</td>
  </tr>
  <tr>
    <td> editor.selectAll();</td>
    <td> select all</td>
  </tr>
  <tr>
    <td> editor.selectNothing();</td>
    <td> select nothing (clear selections)</td>
  </tr>
  <tr>
    <td> editor.cutBuffer</td>
    <td> If a macro was triggered by a key press and there was a selection previous to the key press, the content of the selection is stored in the cutBuffer. The selection and its content is removed before the macro is entered.</td>
  </tr>
  <tr>
    <td> editor.find();</td>
    <td> activate "find panel"</td>
  </tr>
  <tr>
    <td> editor.find(QString text, bool highlight, bool regex, bool word=false, bool caseSensitive=false);</td>
    <td> activate "find panel" with predefined values</td>
  </tr>
  <tr>
    <td> editor.find(QString text, bool highlight, bool regex, bool word, bool caseSensitive, bool fromCursor, bool selection);</td>
    <td> activate "find panel" with predefined values</td>
  </tr>
  <tr>
    <td> editor.findNext();</td>
    <td> find next</td>
  </tr>
  <tr>
    <td> editor.replacePanel();</td>
    <td> replace (if find panel open and something is selected)</td>
  </tr>
  <tr>
    <td> editor.gotoLine();</td>
    <td> activate "goto line panel"</td>
  </tr>
  <tr>
    <td> editor.indentSelection();</td>
    <td> indent selection</td>
  </tr>
  <tr>
    <td> editor.unindentSelection();</td>
    <td> unindent selection</td>
  </tr>
  <tr>
    <td> editor.commentSelection();</td>
    <td> comment selection</td>
  </tr>
  <tr>
    <td> editor.uncommentSelection();</td>
    <td> uncomment selection</td>
  </tr>
  <tr>
    <td> editor.clearPlaceHolders();</td>
    <td> clear place holders</td>
  </tr>
  <tr>
    <td> editor.nextPlaceHolder();</td>
    <td> jump to next place holder</td>
  </tr>
  <tr>
    <td> editor.previousPlaceHolder()</td>
    <td> jump to previous place holder</td>
  </tr>
  <tr>
    <td> editor.setPlaceHolder(int i, bool selectCursors=true);</td>
    <td> set Placeholder</td>
  </tr>
  <tr>
    <td> editor.setFileName(f);</td>
    <td> set filename to <i>f</i></td>
  </tr>
  <tr>
    <td> editor.write(str) </td>
    <td> inserts str at the current cursors position (if there are cursor mirrors, str will be inserted by all of them) </td>
  </tr>
  <tr>
    <td> editor.insertText(str) </td>
    <td> inserts str at the current cursor position (cursor mirrors are ignored, so it is preferable to use replaceSelectedText or write instead) </td>
  </tr>
  <!--
  <tr>
    <td> editor.insertText(cursor, str) </td>
    <td> inserts str at the position of cursor </td>
  <tr>-->
  <tr>
    <td> editor.setText(<i>text</i>) </td>
    <td> replace the whole text of the current document by <i>text</i> </td>
  </tr>
  <tr>
    <td> editor.text()</td>
    <td> return the text of the complete document</td>
  </tr>
  <tr>
    <td> editor.text(int line)</td>
    <td> return text of <i>line</i></td>
  </tr>

  <tr><th colspan=2>Document object</th></tr>
<tr><td>editor.document().lineCount() </td><td>   Returns the number of lines     </td></tr>
<tr><td>editor.document().visualLineCount() </td><td>    Returns the number of visual lines (counting wrapped lines)    </td></tr>
<tr><td>editor.document().cursor(line, [column = 0], [lineTo = -1], [columnTo = length of lineTo]) </td><td>  Returns a cursor object. If lineTo is given the cursor has a selection from line:column to lineTo:columnTo, otherwise not.   </td></tr>
<tr><td>editor.document().text([removeTrailing = false], [preserveIndent = true]) </td><td>  Returns the complete text of the document </td></tr>
<tr><td>editor.document().textLines() </td><td>   Returns an array of all text lines     </td></tr>
<tr><td>editor.document().lineEndingString() </td><td> Returns a string containing the ending of a line (\n or \n\r)       </td></tr>
<tr><td>editor.document().canUndo() </td><td>   Returns true if undo is possible     </td></tr>
<tr><td>editor.document().canRedo() </td><td>    Returns true if redo is possible    </td></tr>
<tr><td>editor.document().expand(lineNr)</td><td>    Expands the line    </td></tr>
<tr><td>editor.document().collapse(lineNr)</td><td>   Collapse the line     </td></tr>
<tr><td>editor.document().expandParents(lineNr)</td><td>  Expand all parents of the line until it is visible     </td></tr>
<tr><td>editor.document().foldBlockAt(bool unFold, lineNr);</td><td>  Collapses or expands the first block before lineNr     </td></tr>
<tr><td>editor.document().getMasterDocument();</td><td>  Returns the open document which directly includes this document  </td></tr>
<tr><td><s>editor.document().getTopMasterDocument();</s></td><td><i>Deprecated:</i> Use getRootDocument() instead</td></tr>
<tr><td>editor.document().getRootDocument();</td><td>  Returns the open document which indireclty includes this document and is not itself included by any other document </td></tr>
<tr><td>editor.document().getMagicComment(name);</td><td>  Returns the content of a magic comment, if it exists   </td></tr>
<tr><td>editor.document().updateMagicComment(name, value, [create = false]);</td><td>  Changes a magic comment  </td></tr>
<tr><td>editor.document().labelItems/refItems/bibItems</td><td>  Returns the ids of all labels/references or included bibliography files. </td></tr>
<tr><td>editor.document().getLastEnvName(lineNr)</td><td>  Returns the name of the current environment (at the end of the line). </td></tr>

  <tr><th colspan=2>Document Manager object</th></tr>
  <tr><td>documentManager.currentDocument </td><td>   Current document (usually the same as editor.document(), unless the script is running in background mode) </td></tr>
  <tr><td>documents.masterDocument </td><td>   Master document </td></tr>
  <tr><td>[documentManager.]documents</td><td>   Array of all open documents     </td></tr>
  <tr><td>documentManager.findDocument(fileName) </td><td>   Returns the open document with a certain file name  </td></tr>
  <tr><td>documentManager.singleMode() </td><td>   Returns if there is no explicit master document  </td></tr>
  <tr><td><s>documentManager.getMasterDocumentForDoc(document)</s></td><td>  <i>Deprecated:</i> Use getRootDocumentForDoc(document) instead </td></tr>
  <tr><td>documentManager.getRootDocumentForDoc(document)</td><td>   Returns the open document (possibly indirectly) including the given document </td></tr>
  <tr><td>documentManager.findFileFromBibId(id) </td><td>   Returns the file name of the bib file containing an entry with the given id  </td></tr>


  <tr>
  <th colspan=2>Cursor object</th>
  </tr>

  <tr>
    <td> cursor.atEnd()
    <td> returns whether the cursor is at the end of the document
  </tr>
  <tr>
    <td> cursor.atStart()
    <td> returns whether the cursor is at the start of the document
  </tr>
  <tr>
    <td> cursor.atBlockEnd()
    <td> returns whether the cursor is at the end of a block
  </tr>
  <tr>
    <td> cursor.atBlockStart()
    <td> returns whether the cursor is at the start of a block
  </tr>
  <tr>
    <td> cursor.atLineEnd()
    <td> returns whether the cursor is at the end of a line
  </tr>
  <tr>
    <td> cursor.atLineStart()
    <td> returns whether the cursor is at the start of a line
  </tr>
  <tr>
    <td> cursor.hasSelection()
    <td> return whether the cursor has a selection
  </tr>
  <tr>
    <td> cursor.lineNumber()
    <td> returns the line number of the cursor
  </tr>
  <tr>
    <td> cursor.columnNumber()
    <td> returns the column of the cursor
  </tr>
  <tr>
    <td> cursor.anchorLineNumber()
    <td> returns the line number of the anchor.
  </tr>
  <tr>
    <td> cursor.anchorColumnNumber()
    <td> returns the column of the anchor.
  </tr>
  <tr>
    <td> cursor.shift(int offset)
    <td>Shift cursor position (text column) by a number of columns (characters)
  </tr>
  <tr>
    <td> cursor.setPosition(int pos, MoveMode m = MoveAnchor)
    <td> set the cursor position after pos-characters counted from document start (very slow)
  </tr>
  <tr>
    <td> cursor.movePosition(int offset, MoveOperation op = NextCharacter, MoveMode m = MoveAnchor);
    <td> move cursor <i>offset</i> times. MoveOperations may be:
      <ul>
	<li>cursorEnums.NoMove
	<li>cursorEnums.Up
	<li>cursorEnums.Down
	<li>cursorEnums.Left
	<li>cursorEnums.PreviousCharacter = Left
	<li>cursorEnums.Right
	<li>cursorEnums.NextCharacter = Right
	<li>cursorEnums.Start
	<li>cursorEnums.StartOfLine
	<li>cursorEnums.StartOfBlock = StartOfLine
	<li>cursorEnums.StartOfWord
	<li>cursorEnums.StartOfWordOrCommand
	<li>cursorEnums.PreviousBlock
	<li>cursorEnums.PreviousLine = PreviousBlock
	<li>cursorEnums.PreviousWord
	<li>cursorEnums.WordLeft
	<li>cursorEnums.WordRight
	<li>cursorEnums.End
	<li>cursorEnums.EndOfLine
	<li>cursorEnums.EndOfBlock = EndOfLine
	<li>cursorEnums.EndOfWord
	<li>cursorEnums.EndOfWordOrCommand
	<li>cursorEnums.NextWord
	<li>cursorEnums.NextBlock
	<li>cursorEnums.NextLine = NextBlock
      </ul>
      Options for MoveMode are:
      <ul>
	<li>cursorEnums.MoveAnchor
	<li>cursorEnums.KeepAnchor
	<li>cursorEnums.ThroughWrap
      </ul>
  </tr>
  <tr>
    <td> cursor.moveTo(int line, int column);
    <td> move cursor to <i>line</i> and <i>column</i>
  </tr>
  <tr>
    <td> cursor.eraseLine();
    <td> remove current line
  </tr>
  <tr>
    <td> cursor.insertLine(bool keepAnchor = false);
    <td> insert empty line
  </tr>
  <tr>
    <td> cursor.insertText(text, bool keepAnchor = false)
    <td> insert <i>text</i> text at cursor (this function will ignore indentations and mirrors, see editor.write and editor.insertText)
  </tr>
  <tr>
    <td> cursor.selectedText()
    <td>return the selected text
  </tr>
  <tr>
    <td> cursor.clearSelection();
    <td>clears selection
  </tr>
  <tr>
    <td> cursor.removeSelectedText();
    <td> removes selected text
  </tr>
  <tr>
    <td> cursor.replaceSelectedText(text);
    <td> replace selected text with <i>text</i>
  </tr>
  <tr>
    <td> cursor.deleteChar();
    <td> removes char right to the cursor
  </tr>
  <tr>
    <td> cursor.deletePreviousChar();
    <td> removes char left to the cursor
  </tr>
  <tr>
    <td> cursor.beginEditBlock();
    <td> begins a new edit block. All cursor operations encapsulated in an edit block are undone/redone at once.
  </tr>
  <tr>
    <td> cursor.endEditBlock();
    <td> ends an edit block
  </tr>
  <tr><th colspan=2>App object</th></tr>
  <tr><td>app.getVersion()</td><td>Current version (0xMMmm00)</td></tr>
  <tr><td>app.clipboard</td><td>Property to read/write to the clipboard</td></tr>
  <tr><td>app.getCurrentFileName()</td><td>File name of currently edited file</td></tr>
  <tr><td>app.getAbsoluteFilePath(rel, ext = "")</td><td>Converts a relative filename to an absolute one</td></tr>
  <tr><td>app.load(file)</td><td>Loads an file </td></tr>
  <tr><td>app.fileOpen/Save/Close/.../editUndo/.../QuickBuild/... </td><td>All menu commands (i.e. all slots in the texmaker.h file). You can view a list of all currently existing slots on the "menu" page of the config dialog.</td></tr>
  <tr><td>app.newManagedMenu([parent menu,] id, caption)</td> <td>Creates a new menu and returns it</td></tr>
  <tr><td>app.getManagedMenu(id)</td> <td>Returns a <a href="http://developer.qt.nokia.com/doc/qt-4.8/QMenu.html">QMenu</a> with a certain id</td></tr>
  <tr><td>app.newManagedAction(menu, id, caption)<!--, [slot, [shortCut, [icon]]])--></td> <td>Creates a new action and returns it<br>
    <ul><li>menu: Parent menu</li>
    <li>id: Id of the new action (the final, unique id will be <i>menu id/action id</i>)</li>
    <li>caption: Visible text</li>
<!--    <li>slot: qt-slot-id if the action should be connected to a slot of app</li>
    <li>shortCut: default shortcut for the new action</li>
    <li>icon: icon</li>-->
    </ul>
    You can use action.triggered.connect(function(){ ... }); to link a function to the returned action (for details see the <a href="http://developer.qt.nokia.com/doc/qt-4.8/scripting.html#signal-to-function-connections">qt signal/slot</a> documentation).
  </td></tr>
  <tr><td>app.getManagedAction([id])</td> <td>Returns an <a href="http://developer.qt.nokia.com/doc/qt-4.8/QAction.html">QAction</a> with a certain id (all ids have the form main/menu1/menu2/.../menuN/action, with usually one menu, e.g. "main/edit/undo", see texmaker.cpp) </td></tr>
  <tr><td>app.createUI(file, [parent])</td><td>Loads a certain ui file and creates a QWidget* from it</td></tr>
  <tr><td>app.createUIFromString(string, [parent])</td><td>Creates a QWidget* described in the string</td></tr>
  <tr><td>app.slowOperationStarted()/slowOperationEnded()</td><td>Notify txs about the start/end of a slow operation to temporary disable the endless loop detection.</td></tr>
  <tr><td>app.simulateKeyPress(shortcut)</td><td>Trigger a KeyPress event for the given shortcut, e.g. <code>app.simulateKeyPress("Shift+Up")</code>. <i>Note</i>: this is mainly intended for shortcuts and navigation. Currently, it does not support all functions of a KeyPress event. In particular, you cannot type any text.</td></tr>

  <tr><th colspan=2>UniversalInputDialog class</th></tr>
  <tr><td>new UniversalInputDialog()</td><td>Creates a new dialog</td></tr>
  <tr><td>dialog.add(defaultValue, [description, [id]])</td><td>Adds a new variable with the given default value, optional description and id to the dialog; and returns the corresponding qt component. <br> A string default value becomes a QLineEdit, a number a QSpinBox and an array a QComboBox.</td></tr>
  <tr><td>dialog.get(nr/id)</td><td>Returns the current value of the nr-th added variable or the variable with a certain id.</td></tr>
  <tr><td>dialog.getAll()</td><td>Returns the value of all variables as combined numerical/associative array. You can use returnvalue[i] to get the i-th variable, and returnvalue.id to get the variable with a certain id.</td></tr>
  <tr><td>dialog.exec()</td><td>Displays the dialog. Returns 1 if the user accepted the dialog, 0 if it was canceled.</td></tr>
  <tr><td>dialog.show()</td><td>Displays the dialog asynchronously.</td></tr>
  <tr><td>UniversalInputDialog([[defaultValue_0, description_0, id_0], [defaultValue_1, description_1, id_1], ...])</td><td>Short form: Creates a new dialog, adds all variables of the array and call exec on it.</td></tr>
  <tr><th colspan=2>FileChooser object</th></tr>
  <tr>
	<td> fileChooser.exec()
	<td> show dialog and wait until it is closed again
  </tr>
  <tr>
	<td> fileChooser.setDir(dir)
	<td> set directory in the dialog to <i>dir</i>
  </tr>
  <tr>
	<td> fileChooser.setFilter(filter)
	<td> set file filter to <i>filter</i>, using the QT-format, see above
  </tr>
  <tr>
	<td> fileChooser.fileName()
	<td> return selected filename (after exec)
  </tr>
</table>

<br><br>
<p>Some examples:</p>
<ul>
<li>Copy current file name to clipboard: <pre>
%SCRIPT
app.clipboard = editor.fileName();</pre>
</li>
<li>Execution of editor text: <pre>
%SCRIPT
eval(editor.text());</pre>
</li>
<li>Show all properties of an object: <pre>
%SCRIPT
function write_properties(obj) {
    app.fileNew();
    newEditor = documentManager.currentDocument.editorView.editor;   //access the newly created document
    newEditor.setText(Object.getOwnPropertyNames(obj).join("\n"));   //print the properties
}

obj = editor;                                                        //object to show (e.g. the current editor)
write_properties(obj)
</pre>
</li>
<li>Additional action in the edit menu<pre>
%SCRIPT
var menu = app.getManagedMenu("main/edit");                   //get edit menu
var act = app.newManagedAction(menu, "script", "scripttest"); //add action
act.triggered.connect(function(){alert("called");});          //register simple handler
registerAsBackgroundScript("test");                           //keep handler valid</pre></li>
<li>Asynchronous dialog:<pre>
%SCRIPT
var ui = createUI(" ... path to your ui file ...");  //load dialog
ui.accepted.connect(function(){alert("x");})         //react to dialog closing
registerAsBackgroundScript("abc");                   //keep function valid
ui.show();                                           //show dialog
</pre> The dialog is described in an ui file which can be created with the Qt Designer. </li>
</ul>
<p>More examples can be found in the <a href='https://github.com/texstudio-org/texstudio/wiki/Scripts'>Wiki</a>.
<h3 id="sectionTriggers">4.5.4 Triggers</h3>
<h4>4.5.4.1 Regular Expressions</h4>
<p>In its simplest form, the trigger is simply a text, which is replaced by the macro.
E.g. trigger="eg" macro="example given", "eg" in "the leg" is replaced on pressing "g" by "example given"<br>
As the trigger is a regular expression, more elaborate triggers can be created. TXS makes use of look-behind searching: "(?<=\s)%" is used to replace a "%" if the previous character is a space. More help on regular expressions can be found on the internet.</p>
<p>You can access the matched expression in the script via the global variable <code>triggerMatches</code>. <code>triggerMatches</code> is an array. It's zero-th component is the match to the complete regexp. The following elements are matches to groups (if groups are defined).</p>

<p>Example:</p>
<pre>Trigger: #([a-z])
Typed text: #a

triggerMatches[0] == '#a'
triggerMatches[1] == 'a'
</pre>
<p>Note: Triggers are inactive while the completer is active. For example you cannot trigger on <code>\\sec</code> if the completer is open suggesting to complete <code>\section</code>.</p>

<h4>4.5.4.2 Limitation of Scope</h4>
<p>To the scope in which a macro will be active, you can prepend an expression of the pattern <code>(?[scope-type]:...)</code>.</p>
<table>
<tr><th>Scope Limiting Expression</th><th>Meaning</th></tr>
<tr><td><code>(?language:...)</code></td><td>The macro is only active if the highlighting of the document matches the given language.<br>Example: <code>(?language:latex)</code></td></tr>
<tr><td><code>(?highlighted-as:...)</code></td><td>Restrict the macro to certain highlighted environments. The possible values correspond to the list on the syntax highlighting config page.<br>Example: <code>(?highlighted-as:numbers,math-delimiter,math-keyword)</code></td></tr>
<tr><td><code>(?not-highlighted-as:...)</code></td><td>Similar to <code>(?highlighted-as:...)</code>, but the macro is deactivated in the given environments.</td></tr>
</table>
<p>You may combine <code>(?language:...)</code> and <code>(?highlighted-as:...)</code> expressions. However, combing <code>(?highlighted-as:...)</code> and <code>(?not-highlighted-as:...)</code> does not make sense logically and has undefined behavior.
</p>
<p>Note that you still need the regular expression of the trigger itself. Here's a full complex example:
<code>(?language:latex)(?highlighted-as:comment,commentTodo)FIXME</code>. This trigger responds to typing "FIXME", but only in comments and todo-notes of latex documents.
</p>

<h4>4.5.4.3 Event Triggers</h4>
<p>Additionally the following special trigger terms (without parentheses) can be used to execute the script when the corresponding event occurs:<br><br>
<table>
<tr><th>Special Trigger</th><th>Executed on Event</th></tr>
<tr><td>?txs-start</td><td>TeXstudio is started.</td></tr>
<tr><td>?new-file</td><td>A new file is created</td></tr>
<tr><td>?new-from-template</td><td>A new file is created from a template</td></tr>
<tr><td>?load-file</td><td>A file is loaded</td></tr>
<tr><td>?load-this-file</td><td>The file containing the macro is loaded (only makes sense, if the script is defined as <a href="#TEXCOM">magic comment</a>)</td></tr>
<tr><td>?save-file</td><td>A file is saved</td></tr>
<tr><td>?close-file</td><td>A file is closed</td></tr>
<tr><td>?master-changed</td><td>A document is un/defined as master document</td></tr>
<tr><td>?after-typeset</td><td>A latex-like command has ended</td></tr>
<tr><td>?after-command-run</td><td>A command run has ended (e.g. a compile command that calls latex twice and opens the viewer, will trigger this event once, but after-typeset twice)</td></tr>
</table>
<p>Multiple of these special triggers can be combined by | symbols.

<!-- Deprecated:? <p>You can also launch your own commands (shortcuts : Alt+Shift+F1...Alt+Shift+F5). These commands are defined with the "User - User Commands" menu.</p>-->
<h2 id="SECTION34">4.6 Pstricks support</h2>
<p>The main pstricks commands can be inserted with the "Pstricks" panel in the "Structure View".</p>
<h2 id="SECTION35">4.7 Metapost support</h2>
<p>The metapost keywords can be inserted with the "Metapost" panel in the "Structure View" and the "mpost" command can be launched via the "Tools" menu.</p>
<h2 id="SECTION36">4.8 The "Convert to Html" command</h2>
<p>This command (from the "Tools" menu ) produces a set of html pages from a LaTeX source file with one image for each html page. Each page in the slide presentation corresponds to one of the postscript pages you would obtain running LaTeX.<br>
The command also produces an index page corresponding to the table of contents you would obtain with LaTeX. Each item of the index page includes a link to the corresponding html page.</p>
<p>You can create links in the html pages by using the \ttwplink{}{} command in the tex file.<br>
Synopsis :<br>
\ttwplink{http://www.mylink.com}{my text} (external link)<br>
\ttwplink{page3.html}{my text} (internal link)<br>
\ttwplink{name_of_a_label}{my text} (internal link)<br>
<b>Warning : </b>You can't use this command with the hyperref package (and some others packages). This command can only be used with the "Convert to html" tool.</p>
<p><IMG src="doc18.png" border="1" alt="doc18"></p>
<p><IMG src="doc19.png" border="1" alt="doc19"></p>


<h2 id="SECTION37">4.9 "Forward/Inverse search" with TeXstudio</h2>
<h3>Integrated pdf-viewer</h3>
<p>
TeXstudio provides an integarted pdf-viewer which offers forward- and inverse-search. Make sure that synctex is activated in the pdflatex command (option -synctex=1 needs to be added), though TeXstudio will ask you if it can correct the command itself if it is not set correctly.<br>
Forward search is automatically done every time the pdf-viewer is opened. TeXstudio will jump to the position where your cursor is currently positioned. Additionally you can CTRL+left click on a word in the text editor to jump to the pdf or use the context menu and select "Go To PDF".<br>
Inverse can be activated by clicking in the pdf with CTRL+left mouse button or by slecting "jump to source" in the context menu, which is activated with a right mouse button click.
Furthermore it is possible to enable "Scrolling follows Cursor" in pdf-viewer/configure. This will keep the pdf-viewer position synchronous to your cursor opposition in the editor.
Likewise "Cursor follows Scrolling"  keeps the editor position synchronous to pdf-viewer position.
</p>

<h3>General Set-up for external viewers</h3>
<p>
Some (dvi) viewers can jump to (and visually highlight) a position in the DVI file that corresponds to a certain line number in the (La)TeX source file.<br>
To enable this forward search, you can enter the command line of the corresponding viewer either as command line for an user tool in the User menu (User/User Commands/Edit...) or in the viewer command line in the config dialog  ("Options/Configure TeXstudio" -> "Commands").
When the viewer is launched, the <b>@</b>-placeholder will be replaced by the current line number and <b>?c:ame</b> by the complete absolute filename of the current file.<br><br>
On Windows, you can execute DDE commands by inserting a command of the form: <span class="command">dde:///service/control/[commands...]</span> or (since TeXstudio 1.9.9) also <span class="command">dde:///programpath:service/control/[commands...]</span> to start the program if necessary.
<br><br>
Below you can find a list of commands for some common viewers. Of course, you have to replace <i>(your program path)</i> with the path of the program on your computer, if you want to use a command.<br>
</p>

<h3>Sumatra</h3>
<p>
Launch Sumatra from TeXstudio and configure Sumatra for inverse search: <span class="command">"<i>(your sumatra path)</i>" -reuse-instance -inverse-search "\"<i>(your TeXstudio path)</i>\" \"%%f\" -line %%l" "?am.pdf"</span><br><br>
Jump to a line in a running Sumatra (Windows only): <span class="command">dde:///SUMATRA/control/[ForwardSearch("?am.pdf","?c:am.tex",@,0,0,1)]</span><br><br>
Launch Sumatra if it is not running and jump to a line in it (Windows only): <span class="command">dde:///<i>(your sumatra path)</i>:SUMATRA/control/[ForwardSearch("?am.pdf","?c:am.tex",@,0,0,1)]</span><br><br>
Launch TeXstudio from Sumatra: <span class="command">"<i>(your TeXstudio path)</i>" "%f" -line %l </span><br><br>

A possible value for <i>(your Sumatra path)</i> is <span class="command">C:/Program Files/SumatraPDF/SumatraPDF.exe</span>
</p>

<h3>Foxit Reader</h3>
<p>
Launch Foxit Reader from TeXstudio: <span class="command">"<i>(your Reader path)"</i> "?am.pdf"</span><br><br>
</p>

<h3>Acrobat Reader</h3>
<p>
Launch Acrobat Reader from TeXstudio: <span class="command">"<i>(your Reader path)"</i> "?am.pdf"</span><br><br>

Naviation and closing are achieved via DDE commands. Since version 10 of the adobe products the DDE service name contains a letter for the Product and the version number.</p>
<table>
<tr><th>Product</th><th>Service name</th></tr>
<tr><td>Adobe Reader 9</td><td>acroview</td></tr>
<tr><td>Adobe Acrobat 9</td><td>acroview</td></tr>
<tr><td>Adobe Reader 10</td><td>acroviewR10</td></tr>
<tr><td>Adobe Acrobat 10</td><td>acroviewA10</td></tr>
<tr><td>Adobe Reader 11</td><td>acroviewR11</td></tr>
<tr><td>Adobe Acrobat 11</td><td>acroviewA11</td></tr>
<tr><td>Adobe Reader DC</td><td>acroviewR15</td></tr>
<tr><td>Adobe Acrobat DC</td><td>acroviewA15</td></tr>
</table>
<p>
The following example is for Adobe Reader DC:<br>
Jump to a position in a running Adobe Reader (Windows only): <span class="command">dde:///acroviewR15/control/[DocOpen("?am.pdf")][FileOpen("?am.pdf")][DocGotoNameDest("?am.pdf","jump-position")]</span> &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;<i>jump-position can be defined with the hyperref package</i><br>
If you have the problem that Adobe Reader does not open, you have to add the program path like this: <span class="command">
dde:///"C:\Program Files (x86)\Adobe\Acrobat Reader DC\Reader\AcroRd32.exe":acroviewR15/control/[DocOpen("?am.pdf")][FileOpen("?am.pdf")][DocGotoNameDest("?am.pdf","jump-position")]</span><br><br>

Close the document in a running Adobe Reader (Windows only): <span class="command">dde:///acroviewR15/control/[DocOpen("?am.pdf")][FileOpen("?am.pdf")][DocClose("?am.pdf")]</span><br><br>

Note: Since Adobe Reader blocks writing to PDFs which are open in the Reader, you have to close the PDF before recompiling. You can define a User Command for the above DDE-command and call it at the beginning of your build chain. This ensures that the file will be closed and thus is writable when compiling.
</p>

<h3>Yap (Yet Another Previewer)</h3>
<p>
Launch Yap from TeXstudio: <span class="command">"<i>(your Yap path)</i>" -1 -s @?c:m.tex %.dvi</span>
<br><br>
Launch TeXstudio from Yap: <span class="command">"<i>(your TeXstudio path)</i>" "%f" -line %l </span><br><br>

A possible value for <i>(your Yap path)</i> is <span class="command">C:\Program Files\MiKTeX 2.7\miktex\bin\yap.exe</span>
</p>

<h3>xdvi</h3>
<p>
Launch xdvi from TeXstudio: <span class="command">xdvi %.dvi  -sourceposition @:?c:m.tex</span><br><br>

Launch xdvi from TeXstudio and enable inverse search: <span class="command">xdvi -editor "texstudio %f -line" %.dvi -sourceposition @:%.tex</span>
</p>

<h3>kdvi</h3>
<p>
Launch kdvi from TeXstudio: <span class="command">kdvi "file:%.dvi#src:@ ?c:m.tex"</span>
</p>

<h3>Okular</h3>
<p>
Launch okular from TeXstudio: <span class="command">okular --unique %.dvi#src:@?c:m.tex</span><br><br>
Launch TeXstudio from Okular: <span class="command">texstudio %f -line %l</span>
</p>

<h3>Skim</h3>
<p>
Launch Skim from TeXstudio: <span class="command">(your Skim path)/Contents/SharedSupport/displayline @ ?am.pdf ?c:ame</span><br><br>
Launch TeXstudio from skim: Command: <span class="command">/applications/texstudio.app/contents/macos/texstudio</span> with arguments: <span class="command">"%file" -line %line </span><br><br>
A possible value for <i>(your Skim path)</i> is <span class="command">/Applications/Skim.app</span>
</p>

<h3>qpdfview</h3>
<p>
Launch qpdfview from TeXstudio: <span class="command">qpdfview --unique ?am.pdf#src:?c:am.tex:@:0 2> /dev/null</span><br><br>
Launch TeXstudio from qpdfview: <span class="command">texstudio "%1" -line %2</span>
</p>

<h2 id="TEXCOM">4.10 Advanced header usage</h2>
<p>So called "magic comments" are a way to adapt the options of the editor on a per-document level. The concept was <a href="http://www.texdev.net/2011/03/24/texworks-magic-comments/">originally introduced in TeXshop</a> and has been adopted in a number of editors since. TeXstudio supports the following magic comments:</p>
<ul class="magiccomments">
<li>
<code>% !TeX spellcheck = de_DE</code>
<p>Defines the language used for spell checking of the document. This overrides the global spellchecking settings. Nevertheless, an appropriate dictionary has to be installed.</p>
</li>
<li>
<code>% !TeX encoding = utf8</code>
<p>Defines the character encoding of a document.
</li>
<li>
<code>% !TeX root = filename</code>
<p>Defines the root document for this file (i.e. the file which will be passed to the LaTeX compiler when building). This setting override the automatic root detection in TeXstudio. In turn, it's overridden, if an <i>explicit root document</i> is set at <code>Options -> Root Document</code>.</p>
</li>
<li>
<code>% !TeX program = pdflatex</code>
<p>Defines the compiler to be used for the document. To be precise, it overrides the default compiler (command <code>txs:///compile</code>) which is used in the actions "Build & View" as well as "Compile". Valid options are "latex","pdflatex","xelatex","lualatex" and "user<i>n</i>" (e.g. user0 as user defined command 0)
</li>
<li>
<code>% !TeX TXS-program:bibliography = txs:///biber</code>
<p>This is a TeXstudio-specific setting. It overrides the build-system command specified to the left by the one on the right. In the example, we tell TXS to use the biber command (<code>txs:///biber</code>) for the general "Bibliography command (txs:///bibliography). See also the <a href="#SECTION02a1">description of the build system</a>.</p>
</li>
<li>
<code>
% !TeX TXS-SCRIPT = foobar <br>
% //Trigger = ?load-this-file <br>
% app.load("/tmp/test/test.tex"); <br>
% app.load("/tmp/test/a.tex"); <br>
% TXS-SCRIPT-END
</code>
<p>This defines a temporary script macro which is executed, when the file is loaded, and which in turns loads the two files in /tmp/test. .
<p>The macros defined via TXS-SCRIPT are active in all files of a document (e.g. included files). You cannot run them manually. They are run via
the trigger (regular expression or special trigger, see section on triggers). The macro is just read once, when the file is opened.
Changes during an edit session will only take effect when you reopen the file.
</li>
<li>
<code>% !BIB program = biber</code>
<p>The special <code>% !BIB program</code> command is understood for compatibility with TeXShop and TeXWorks (also in the variant <code>% !BIB TS-program</code>). This is equivalent to <code>% !TeX TXS-program:bibliography = txs:///biber</code></p>
</li>
</ul>
<h2 id="TEXSTUDIO-CMD">4.11 Synopsis of the TeXstudio command</h2>
<p>
<code>texstudio file [--config DIR] [--root] [--line xx[:cc]] [--insert-cite citation] [--start-always] [--pdf-viewer-only] [--page yy] [--no-session]</code><br><br>
<table>
<tr><td><code>--config DIR</code></td><td>use the specified settings directory.</td></tr>
<tr><td><code>--ini-file FILE</code></td><td><i>deprecated</i>:use <code>--config</code> instead.</td></tr>
<tr><td><code>--root</code></td><td>defines the document as <i>explicit root document</i> (formerly called <i>master document</i>).</td></tr>
<tr><td><code>--master</code></td><td><i>deprecated</i>:use <code>--root</code> instead.</td></tr>
<tr><td><code>--line xx[:cc]</code></td><td>position the cursor at line LINE and column COL, e.g. "--line 2:5" will jump to column 5 in line 2.</td></tr>
<tr><td><code>--insert-cite citation</code></td><td>pushes a bibtex key to TeXstudio, that will be inserted at the cursor position. This is intended as an interface for external bibliography managers to push citations to TeXstudio. You may either pass an (also custom) command like \mycite{key} or just the key. In the latter case, it is expanded to \cite{key}. Also comma separated keylists are supported. TeXstudio recognizes, if the cursor is already within a citation macro. If so, only the key is inserted at an appropriate position, otherwise the full citation command is inserted.</td></tr>
<tr><td><code>--start-always</code></td><td>start a new instance, even if TXS is already running. This allows using of multiple instances.</td></tr>
<tr><td><code>--pdf-viewer-only</code></td><td>run as a standalone pdf viewer without an editor</td></tr>
<tr><td><code>--page</code></td><td>display a certain page in the pdf viewer</td></tr>
<tr><td><code>--no-session</code></td><td>do not load/save the session at startup/close</td></tr>
</table>
</p>
<p>Additional options only available in debug versions of texstudio:
<table>
<tr><td><code>--disable-tests</code></td><td>Prevent running any tests.</td></tr>
<tr><td><code>--execute-tests</code></td><td>Force running the most common tests.</td></tr>
<tr><td><code>--execute-all-tests</code></td><td>Force running all tests.</td></tr>
</table>
Note: The most common tests are run automatically, if there were changes to the executable (i.e. TXS has been compiled since the last run). Furthermore all tests are run once a week.
</p>

<h2 id="SHORTCUTS">4.12 Keyboard shortcuts</h2>
<p>
The keyboard shortcuts can be modified at Options -> Shortcuts.
<p>
The following list is a rough overview of the defaults keyboard shortcuts. Depending on the operating system, there may be some deviations to adapt for OS-specific shortcut conventions.
</p>
<ul class='two-columns'>
<li> "File" menu :
	<ul>
	<li>New : Ctrl+N</li>
	<li>Open : Ctrl+O</li>
	<li>Save : Ctrl+S</li>
	<li>Save as: Ctrl+Alt+S</li>
	<li>Save all: Ctrl+Shift+Alt+S</li>
	<li>Close : Ctrl+W</li>
	<li>Print Source Code : Ctrl+P</li>
	<li>Exit : Ctrl+Q</li>
	</ul>
</li>
<li> "Edit" menu :
	<ul>
	<li>Undo : Ctrl+Z</li>
	<li>Redo : Ctrl+Y</li>
	<li>Copy : Ctrl+C</li>
	<li>Cut : Ctrl+X</li>
	<li>Paste : Ctrl+V</li>
	<li>Select All : Ctrl+A</li>
	<li>Expand Selection to Word : Ctrl+D</li>
	<li>Expand Selection to Line : Ctrl+L</li>
	<li>Delete Line : Ctrl+K</li>
	<li>Delete to End of Line : Alt+K</li>
	<li>Find : Ctrl+F</li>
	<li>Find next : F3 / Ctrl+G</li>
	<li>Find prev : Shift+F3 / Ctrl+Shift+G</li>
	<li>Replace : CTrl+R</li>
	<li>Go to line : Ctrl+G</li>
	<li>Go to previous change: Ctrl+H</li>
	<li>Go to to next change: Ctrl+Shift+H</li>
	<li>Go to Bookmark 0..9: Ctrl+0..9</li>
	<li>Set Bookmark 0..9: Ctrl+Shift+0..9</li>
	<li>Set Unnamed Bookmark: Ctrl+Shift+B</li>
	<li>Next Marker: Ctrl+Down</li>
	<li>Previous Marker: Ctrl+Up</li>
	<li>Go Back : Alt+Left</li>
	<li>Go Forward : Alt+Right</li>
	<li>Insert Unicode Character : Ctrl+Alt+U</li>
	</ul>
</li>
<li> "Idefix" menu :
	<ul>
	<li>Erase Word/Cmd/Env: Alt+Del</li>
	<li>Paste as LaTeX: Ctrl+Shift+V</li>
	<li>Show preview : Alt+P</li>
	<li>Comment : Ctrl+T</li>
	<li>Uncomment : Ctrl+U</li>
	<li>Next Latex Error: Ctrl+Shift+Down</li>
	<li>Previous Latex Error: Ctrl+Shift+Up</li>
	<li>Next Latex Bad Box: Shift+Alt+Down</li>
	<li>Previous Latex Bad Box: Shift+Alt+Up</li>
	<li>Go to definition: Ctrl+Alt+F</li>
	<li>Normal Completion: Ctrl+Space</li>
	<li>\begin Completion: Ctrl+Alt+Space</li>
	<li>Normal Text Completion: Alt+Shift+Space</li>
	<li>Close Last Open Environment: Alt+Return</li>
	<li>Remove Placeholders: Ctrl+Shift+K</li>
	</ul>
</li>

<li> "Tools" menu :
	<ul>
	<li>Build & View : F5</li>
	<li>Compile : F6</li>
	<li>View : F7</li>
	<li>Bibliography : F8</li>
	<li>Glossary : F9</li>
	<li>Check spelling : Ctrl+:</li>
	<li>Thesaurus : Ctrl+Shift+F8</li>
	</ul>
</li>
<li>"LaTeX" menu :
	<ul>
	<li>item : Ctrl+Shift+I</li>
	<li>Italic : Ctrl+I</li>
	<li>Slanted : Ctrl+Shift+S</li>
	<li>Bold : Ctrl+B</li>
	<li>Typewriter : Ctrl+Shift+T</li>
	<li>Small caps : Ctrl+Shift+C</li>
	<li>Emphasis : Ctrl+Shift+E</li>
	<li>New line : Ctrl+Return</li>
	<li>begin{environment} : Ctrl+E</li>
	<li>Insert reference to next label : Ctrl+Alt+R</li>
	</ul>
</li>
<li>"Math" menu :
	<ul>
	<li>Inline math mode : Ctrl+Shift+M</li>
	<li>Display math mode : Alt+Shift+M</li>
	<li>Numbered equations : Ctrl+Shift+N</li>
	<li>Subscript : Ctrl+Shift+D</li>
	<li>Superscript : CTrl+Shift+U</li>
	<li>Frac : Alt+Shift+F</li>
	<li>Dfrac : Ctrl+Shift+F</li>
	<li>Sqrt : Ctrl+Shift+Q</li>
	<li>Left : Ctrl+Shift+L</li>
	<li>Right : Ctrl+Shift+R</li>
	</ul>
</li>
<li>"User" menu :
	<ul>
	<li>User tags : Shift+F1...Shift+F10</li>
	<li>User commands : Shift+Alt+F1...Shift+Alt+F10</li>
	</ul>
</li>
<li>"View" menu :
	<ul>
	<li>Previous Document : Ctrl+PgDown</li>
	<li>Next Document : Ctrl+PgUp</li>
	<li>Focus Editor : Ctrl+Alt+Left</li>
	<li>Focus Viewer : Ctrl+Alt+Right</li>
	<li>Close Something : Esc</li>
	<li>Editor Zoom In : Ctrl++</li>
	<li>Editor Zoom Out : Ctrl+-</li>
	<li>Fullscreeen Mode : F11</li>
	</ul>
</li>
</ul>
<h2 id="CWLDESCRIPTION">4.13 Description of the cwl format</h2>
<p>cwl stands for completion word list and is a file format originally used in Kile to define the commands listed in the completer. TeXstudio uses an extended format of cwls to include additional semantic information and allow for cursor and placeholder placement. It uses them for the following purposes:</p>
<ul>
<li>Populating the autocompletion</li>
<li>Knowledge on the valid commands in the current document (depending on \usepackage statements)</li>
<li>Semantic information that provide additional context in the editor; e.g. a \ref-like command will check for the existence of the referenced label</li>
</ul>
<h3>4.13.1 cwl file format</h3>
<p>
Each line of a cwl file defines a command. Comment lines are possible and start with <code>#</code>. The command syntax is</p>
<p><code>&lt;command&gt;[#classification]</code><br></p>
<p>If no classification is given, the command is considered valid at any position in a LaTeX document. The char <code>#</code> cannot be used inside a <code>command</code>, as it has special meaning:</p>
<ul>
  <li><code>#include:&lt;packagename&gt;</code> (at start of line): also load packagename.cwl. This should be used to indicate that a package depends on other packages.</li>
  <li><code>#repl:&lt;search&gt; &lt;replacement&gt;</code> (at start of line): define a letter replacement, e.g. "a -> ä for German. Only used for letter replacement in spell checking (babel)</li>
  <li><code>#keyvals:&lt;command[,command,...]&gt;</code> (at start of line): start definition of keyvals for <code>command</code>, see graphicx.cwl in source code. To specify possible values for keys, add them after #  e.g. <code>mode=#text,math</code><br>
  Instead of single keys/values, complete special lists can be given, e.g. <code>color=#%color</code>, see also tikz.cwl.<br>
  <code>command</code> can consist of two parts, e.g. \documentclass/thesis which is only valid when the command \documentclass uses thesis as argument.<br>
  If #c is added, the keyvals are only used for completion, not for syntax checking<br>
  If ##L is added to a key, a length is expected as argument.<br>
  If ##l is added to a key, the argument is defining a label. (see listings.cwl)<br>
  </li>
  <li><code>#endkeyvals</code> (at start of line): end definition of keyvals, see graphicx.cwl in source code</li>
  <li><code>#ifOption:&lt;option&gt;</code> (at start of line): the following block is only loaded if &lt;option&gt; was used in the usepackage command, e.g. \usepackage[svgnames]{color} -> option=svgnames</li>
  <li><code>#endif</code> (at start of line): end conditional block</li>
  <li><code>#</code> (at start of line with the exception of <code>#include,#repl,#keyvals or #endkeyvals </code>): This line is a comment and will be ignored.</li>
  <li><code>#</code> (in the middle of a line): Separates the command from the classification</li>
</ul>
<p>cwl files should be encoded as UTF-8.</p>
<h3>4.13.2 Command format</h3>
<p>In its simplest form the command is just a valid LaTeX expression as you find it in the documentation, e.g. <code>\section{title}</code>. By default, every option is treated as a placeholder. Alteratively, you may either just define a stop position for the cursor by <code>%|</code> (Example: <code>\left(%|\right)</code>) or use <code>%< %></code> to mark only part of an option as placeholder (Example: <code>\includegraphics[scale=%<1%>]{file}</code>). New lines can be included in a command by <code>%\</code>.</p>
<h4>Argument Names</h4>
<p>The argument names are visible in the completer window and after completion as placeholders in the editor. In general, you are free to name the arguments as you like. We encurage to provide meaningful names e.g. <code>\parbox[position]{width}{text}</code> instead of <code>\parbox[arg1]{arg2}{arg3}</code>.</p>
<p>There are a few argument names that have special meaning:</p>
<ul>
  <li><code>text</code> or ends with <code>%text</code>: The spellchecker will operate inside this argument (by default arguments are not spellchecked).</li>
  <li><code>title</code>, <code>short title</code> or ends with <code>%title</code>: The spellchecker will operate inside this argument (by default arguments are not spellchecked). Furthermore the argument will be set in bold text (like in section)</li>
  <li><code>bibid</code> and <code>keylists</code>: If used in a command classified as "C". See the classifier description below.</li>
  <li><code>cmd</code> and <code>command</code> or ends with <code>%cmd</code>: definition for command, e.g. \newcommand{cmd}. This "cmd" will considered to have no arguments and convey no functionality.</li>
  <li><code>def</code> and <code>definition</code>: actual definition for command, e.g. \newcommand{cmd}{definition}. This "definition" will ignored for syntax check.</li>
  <li><code>args</code>: number of arguments for command, e.g. \newcommand{cmd}[args]{definition}.</li>
  <li><code>package</code>: package name, e.g. \usepackage{package}</li>
  <li><code>citekey</code>: definition of new citation key name, e.g. \bibitem{citekey}</li>
  <li><code>title</code> and <code>short title</code>: section name, e.g. \section[short title]{title}</li>
  <li><code>color</code>: color name, e.g. \textcolor{color}</li>
  <li><code>width</code>, <code>length</code>, <code>height</code> or ends with <code>%l</code>: width or length option e.g. \abc{size%l}</li>
  <li><code>cols</code> and <code>preamble</code>: columns definition in tabular, etc., e.g. \begin{tabular}{cols}</li>
  <li><code>file</code>: file name</li>
  <li><code>URL</code>: URL</li>
  <li><code>options</code>: package options, e.g. \usepackage[options]</li>
  <li><code>imagefile</code>: file name of an image</li>
  <li>ends with <code>%todo</code>: The argument is highlighted as todo. Note: To add the element to the todo list in the structure panel, you have to additionally add the classifier <code>D</code>. See todonotes.cwl for an example.</li>
  <li><code>key</code>, <code>key1</code>, and <code>key2</code>: label/ref key</li>
  <li><code>label</code> with option <code>#r</code> or key ending with <code>%ref</code>: ref key</li>
  <li><code>label</code> with option <code>#l</code> or key ending with <code>%labeldef</code>: defines a label</li>

  <li><code>labellist</code>: list of labels as employed by cleveref</li>
  <li><code>bib file</code> and <code>bib files</code>: bibliography file</li>
  <li><code>class</code>: document class</li>
  <li><code>placement</code> and <code>position</code>: position of env</li>
  <li><code>%plain</code>: options ending with <code>%plain</code> are interpreted to have no special meaning. This way, you can e.g. define <code>label%plain</code> to have a placeholder named <code>label</code> without the semantics that it defines a label.</li>
  <li><code>beamertheme</code>: beamer theme, e.g. \usebeamertheme{beamertheme}</li>
  <li><code>keys</code>, <code>keyvals</code>, <code>%&lt;options%&gt;</code> or ends with <code>%keyvals</code>: key/value list</li>
  <li><code>envname</code> and <code>environment name</code>: environment name for \newtheorem, e.g. \newtheorem{envname}#N (classification N needs to be present !)</li>
</ul>
<p>A %-suffix takes precedence over detection by name, i.e. an argument <code>file%text</code> will be treated as text not as file.</p>
<h3>4.13.3 Classification format</h3>
<p>The following classifications are known to TXS:</p>
<table>
<tr><th>Classifier</th><th>Meaning</th></tr>
  <tr><td>*</td><td>unusual command which is used for completion only in with the "all" tab. This marker may be followed by other classifications.</td></tr>
  <tr><td>S</td><td>do not show in completer at all. This marker may be followed by other classifications.</td></tr>
  <tr><td>M</td><td>do not use this as command description.</td></tr>
  <tr><td>m</td><td>valid only in math environment</td></tr>
  <tr><td>t</td><td>valid only in tabular environment (or similar)</td></tr>
  <tr><td>T</td><td>valid only in tabbing environment</td></tr>
  <tr><td>n</td><td>valid only in text environment (i.e. not math env)</td></tr>
  <tr><td>r</td><td>this command declares a reference like "\ref{key}"</td></tr>
  <tr><td>c</td><td>this command declares a citation like "\cite{key}"</td></tr>
  <tr><td>C</td><td>this command declares a complex citation like "\textcquote{bibid}{text}". The key needs to be given as <code>bibid</code></td></tr>
  <tr><td>l</td><td>this command declares a label like "\label{key}"</td></tr>
  <tr><td>d</td><td>this command declares a definition command like "\newcommand{cmd}{def}"</td></tr>
  <tr><td>g</td><td>this command declares an include graphics command like "\includegraphics{file}"</td></tr>
  <tr><td>i</td><td>this command declares an include file command like "\include{file}"</td></tr>
  <tr><td>u</td><td>this command declares an used package like "\usepackage{package}"</td></tr>
  <tr><td>b</td><td>this command declares a bibliography like "\bibliography{bib}"</td></tr>
  <tr><td>U</td><td>this command declares a url command like "\url{URL}, where URL is not checked"</td></tr>
  <tr><td>K</td><td>this command declares a bracket-like command like "\big{"</td></tr>
  <tr><td>D</td><td>this command declares a todo item (will be added to the todo list in the side panel). Note: To highlight the item in the editor, you have to additionally add the suffix <code>%todo</code>. See todonotes.cwl for an example.</li>
</td></tr>
  <tr><td>B</td><td>this command declares a color (will be used for color completion only, no syntax checking)</td></tr>
  <tr><td>s</td><td>this command declares a special definition, the definition class is given after a "#". The class name needs a preceding %. (e.g. %color), also see the examples below.</td></tr>
  <tr><td>V</td><td>this command declares a verbatim-like environment "\begin{Verbatim}"</td></tr>
  <tr><td>N</td><td>this command declares a newtheorem-like command like "\newtheorem{envname}"</td></tr>
  <tr><td>L0 to L5</td><td>this command declares a structure command. The level is between L0 (<code>\part</code>-like) down to L5 (<code>\subparagraph</code>-like). Structure commands are highlighted in the code, can be folded and appear in the structure outline.</td></tr>
  <tr><td>/env1,env2,...</td><td>valid only in environment env1 or env2 etc.</td></tr>
  <tr><td>\env</td><td>environment alias, means that the environment is handled like the "env" environment. This is useful for env=math or tabular.</td></tr>
</table>
<p>Examples:<br></p>
<table>
	<tr><th>Line</th><th>Explanation</th></tr>
	<tr><td><code># test</code></td><td>comment</td></tr>
	<tr><td><code>\typein{msg}#*</code></td><td>unusual command which is only shown in completion "all"</td></tr>
	<tr><td><code>\sqrt{arg}#m</code></td><td>only in math mode valid</td></tr>
	<tr><td><code>\pageref{key}#r</code></td><td>declares a reference command which is used correctly for completion</td></tr>
	<tr><td><code>\vector(xslope,yslope){length}#*/picture</code></td><td>unusual command which is valid only in the picture environment</td></tr>
	<tr><td><code>\begin{align}#\math</code></td><td>declares that the "align"-environment is handled like a math-env, concerning command validity and syntax highlighting!</td></tr>
	<tr><td><code>\definecolor{name}{model}{color-spec}#s#%color</code></td><td>adds <code>name</code> to the special list <code>%color</code></td></tr>
	<tr><td><code>\myplot{file}{label}{params}#l</code></td><td>defines the second argument as label. Note: the argument has to be named <code>label</code> for this to work.</td></tr>
	<tr><td><code>\myplot{file}{customname%labeldef}</code></td><td>defines the second argument as label, but you are free to choose the name <code>customname</code> which will be used as a placeholder in the completer.</td></tr>
	<tr><td><code>\myplot{file}{label1%labeldef}{label2%labeldef}</code></td><td>defines the second and third arguments as labels.</td></tr>
</table>
<h3>4.13.4 cwl guidelines</h3>
<p>Though TeXstudio can automatically create cwls from packages, these autogenerated cwls do not contain meaningful argument names and no classification of commands. Therefore we ship hand-tuned cwls for many packages. We encourage users  to contribute new cwl files. These should have the following attributes:</p>
<ul>
  <li><b>package-based:</b> Each cwl should correspond to a package. The exception are some cwls containing fundamental (La)TeX commands, but we've already written them so you should not have to bother. The cwl should be named like the package so that automatic loading works. If you <code>\usepackage{mypackage}</code> TeXstudio will load mypackage.cwl if available.</li>
  <li><b>complete:</b> The cwl should contain all commands in the package. If you use a non-specified command in the editor, the syntaxchecker will mark it as unknown.</li>
  <li><b>specific:</b> The commands should be classified if possible. This allows TeXstudio to give additional context to the command (e.g. warn if a math command is used outside of a math environment or check references and citations.</li>
  <li><b>priorized:</b> Some packages may specify very many commands. Mark the unusual ones by the *-classifier to prevent the completer from overcrowding with rarely used commands.</li>
</ul>

<h3>4.13.5 cwl file placement</h3>
<p>cwl files can be provided from three locations. If present, the user provided cwl is taken, if not built-in versions are taken. As a last resort, txs automatically generates cwls from latex styles, though these only serve to provide syntax information. Context information for arguments are not available and no completion hints are given.</p>
<ul>
<li><b>%appdata%\texstudio\completion\user or .config/texstudio/completion/user</b> user generated cwls</li>
<li><b>built-in</b></li>
<li><b>%appdata%\texstudio\completion\autogenerated or .config/texstudio/completion/autogenerated</b> auto-generated cwls</li>
</ul>


<h2 id="TABLETEMPLATE">4.14 Using table templates</h2>
<p>Texstudio offers the possibility to reformat an existing latex table after a table template.<br>
For example, you have entered following table into txs:
<pre>
\begin{tabular}{ll}
a&amp;b\\
c&amp;d\\
\end{tabular}
</pre>
<p>
Place the cursor inside the table and select the menu "Latex/Manipulate Tables/Remodel Table Using Template".<br>
Now you can select a template which defines the formatting of the table.
A number of templates are predefined by txs:
<ul>
<li>fullyframed_firstBold</li>
<li>fullyframed_longtable</li>
<li>plain_tabular</li>
<li>plain_tabularx</li>
<li>rowcolors_tabular</li>
</ul>
<p>By selecting the first entry, the table is reformated to:
<pre>
\begin{tabular}{|l|l|}
\hline
\textbf{a}&amp;\textbf{b}\\ \hline
c&amp;d\\ \hline
\end{tabular}
</pre>
<p>These templates give the opportunity to easily reformat tables after a predefined fashion, thus achieving a uniform table style in a document, even if the tables are entered in a very simple style.<p>
<h3>4.14.1 Creating table templates</h3>

<p>The templates can be defined by the user as well. They have to be place in the config directory (Linux: ~/.config/texstudio) and need to named after the scheme tabletemplate_<i>name</i>.js.</p>
<p>Meta data is used to provide additional information for the template. It can be stored in a <code>metaData</code> object in the source code. The code <code>var metaData = {</code> has to start on the first line of the file. Currently only string values are accepted. It is possible to use html tags for formatting. Example:</p>
<pre>
var metaData = {
"Name"       : "Colored rows",
"Description" : "Formats the table using alternate colors for rows. &lt;br&gt; &lt;code&gt;\usepackage[table]{xcolor}&lt;/code&gt; is necessary.",
"Author"      : "Jan Sundermeyer",
"Date"        : "4.9.2011",
"Version"     : "1.0"
}
</pre>
<p>The template itself is a javascript (see above) with some prefined variables which contain the whole table. The new table is just placed as replacement of the old one, using information from that variables.
3 variables are given:
<ul>
<li>def   the simplified table definition without any formatting (i.e. ll instead of |l|l|)</li>
<li>defSplit   the table definition split by column (array=l,l,p{2cm})</li>
<li>env   the actual environment name of the old table like "tabular" or "longtable"</li>
<li>tab   the actual table. It is a list of lines, each line is a list of columns which contains the cell content as string</li>
</ul>
<br>
<p>To see the principle of work, the source for the "plain_tabular" template is given here.
<pre>
function print(str){ //define this function to make source more readable
cursor.insertText(str)
}
function println(str){ //define this function to make source more readable
cursor.insertText(str+"\n")
}
var arDef=def.split("") // split the table definition (ll -> 'l' 'l')
println("\\begin{tabular}{"+arDef.join("")+"}") //print table env
for(var i=0;i&lt;tab.length;i++){  // loop through all rows of the table
	var line=tab[i];  // line is a list of all columns of row[i]
	for(var j=0;j&lt;line.length;j++){ // loop through all columns of a row
		print(line[j]) // print cell
		if(j&lt;line.length-1) // if not last columns
			print("&amp;") // print &amp;
	}
	println("\\\\") // close row with \\, note that js demands for backslashes in the string
}
println("\\end{tabular}") // close environment
</pre>
<p>As can be seen in the example, the table has to be rebuilt completely, thus allowing new formatting.
A second example gives a slightly more elaborate table (fullyframed_firstBold):
<pre>
function print(str){
cursor.insertText(str)
}
function println(str){
cursor.insertText(str+"\n")
}
if(env=="tabularx"){
  println("\\begin{tabularx}{\\linewidth}{|"+defSplit.join("|")+"|}")
}else{
    println("\\begin{"+env+"}{|"+defSplit.join("|")+"|}")
}
println("\\hline")
for(var i=0;i&lt;tab.length;i++){
	var line=tab[i];
	for(var j=0;j&lt;line.length;j++){
                var col=line[j];
                var mt=col.match(/^\\textbf/);
                if(i==0 &amp;&amp; !mt)
                  print("\\textbf{")
		print(line[j])
                if(i==0 &amp;&amp; !mt)
                  print("}")
		if(j&lt;line.length-1)
			print("&amp;")
	}
	println("\\\\ \\hline")
}
println("\\end{"+env+"}")
</pre>
</p>

<h1 id="TENTATIVE-FEATURES">5. Tentative Features</h1>
<p>These features allow you to modify core aspects of TeXstudio and thus provide a great flexibility of adapting TeXstudio to your needs. Since these features are either complex or are tightly bound to the internals, we cannot guarantee functionality in all cases and forever. For once, we do not have enough resources to provide full support. Additionally, the dependence on internals conflicts with our need to freely change internals without restriction for future development.</p>
<p>Nevertheless, we decided that these features may be of interest for experiended users. As a compromise, we provide these features tentatively.</p>
<p><strong>We do not guarantee any of this will still be working in future versions. Functionality may change or be removed without notice.</strong></p>

<h2 id="ADVANCED-SCRIPTING">5.1 Advanced Scripting</h2>
<p>You can modify the behavior or add new functionality using <a href="#JAVASCRIPT-MACROS">Script Macros</a>. The section above lists the core commands, but there are more commands which are not documented. A number of them are used in the <a href="https://github.com/texstudio-org/texstudio/wiki/Scripts">examples section in the wiki</a>. The names and signatures of these functions are directly bound to the internal C++ code of TeXstudio and thus may change as we further develop TeXstudio.</p>

<h2 id="STYLESHEETS">5.2 Style Sheets</h2>
<p>Qt supports modifying the appearance of an application using <a href="http://doc.qt.io/qt-5/stylesheet-syntax.html">style sheets</a>. You may use this to adapt the GUI of the main window by placing a file <code>stylesheet.qss</code> into the settings directory. The file is read at program startup.</p>

<p>Please note that the style sheet may interfere with other ways of configuring the GUI, in particular the style color scheme and other options. Therefore we do not guarantee a consistent behavior when using style sheets</p>

<h2 id="LANGUAGEDEF">5.3 Writing your own language definitions</h2>
<p>TeXstudio uses QCodeEdit as editor component. It specifies languages in a special xml format named QNFA. This includes highlighting, parentheses (for matching) and code folding. In a normal TeXstudio installation you won't find any .qnfa files, because we compile the files of the included languages into the binary. You can add your own languages or overwrite the default ones by placing appropriate .qnfa files in a <code>languages</code> folder inside the settings directory. Definitions here take precedence over the builtin ones.</p>

<p>The .qnfa file specifies the syntax of the language. The actual format information is specified in a .qxf file. You can either use the formats specified in <a href="https://github.com/texstudio-org/texstudio/tree/master/utilities/qxs">defaultFormats.qxf</a> or provide your own .qxf file along with the .qnfa file.<p>

<p>You should read the <a href="http://texstudio.sourceforge.net/manual/qce/QNFA.html">syntax format specification</a> and have a look at the <a href="https://github.com/texstudio-org/texstudio/tree/master/utilities/qxs">formats shipped with TeXstudio</a>.<p>


<p>Note: We expose the language specification to you as end-user to give you more flexibility in adapting TeXstudio to your needs. But you should take it as is, because we don't have the capacity to give support here. It's a powerful API, but neither polished nor fully featured. You might find some constructs in the shipped .qnfa files, which are not documented in the syntax format specification. Additionally, the regular-expression based formatting of QNFA is not sufficient to define all the highlighting we wanted for LaTeX. Therefore we have extra highlighting functionality directly implemented in the sourcecode for the "(La)TeX" language, e.g. the highlighting inside the parentheses of <code>\begin</code> and <code>\end</code>. You won't be able to modify this or add it to other languages.<p>

<h3>Example</h3>
<p>The following is a small example which specifies some highlighting of python code:<p>

<p>python.qnfa</p>
<pre>
&lt;!DOCTYPE QNFA&gt;
&lt;QNFA language="Python" extensions="py" defaultLineMark=""&gt;
	&lt;sequence parenthesis="round:open" parenthesisWeight="00"&gt;\(&lt;/sequence&gt;
	&lt;sequence parenthesis="round:close" parenthesisWeight="00"&gt;\)&lt;/sequence&gt;

	&lt;!-- highlight def and function name --&gt;
	&lt;sequence id="python/definition" format="python:definition"&gt;def$s?$w*&lt;/sequence&gt;

	&lt;sequence id="python/number" format="python:number"&gt;[0-9]+&lt;/sequence&gt;

	&lt;list id="python/keyword" format="python:keyword"&gt;
		&lt;word&gt;return&lt;/word&gt;
		&lt;word&gt;if&lt;/word&gt;
		&lt;word&gt;elif&lt;/word&gt;
		&lt;word&gt;else&lt;/word&gt;
	&lt;/list&gt;
&lt;/QNFA&gt;
</pre>

<p>python.qxf</p>
<pre>
&lt;!DOCTYPE QXF&gt;
&lt;QXF version="1.0" &gt;
	&lt;!-- full specification --&gt;
    &lt;format id="python:keyword" &gt;
        &lt;bold&gt;false&lt;/bold&gt;
        &lt;italic&gt;false&lt;/italic&gt;
        &lt;overline&gt;false&lt;/overline&gt;
        &lt;underline&gt;false&lt;/underline&gt;
        &lt;strikeout&gt;false&lt;/strikeout&gt;
        &lt;waveUnderline&gt;false&lt;/waveUnderline&gt;
        &lt;foreground&gt;#B200FF&lt;/foreground&gt;
    &lt;/format&gt;
	&lt;!-- but it is sufficient to specify deviations from default --&gt;
    &lt;format id="python:number" &gt;
        &lt;italic&gt;true&lt;/italic&gt;
        &lt;overline&gt;false&lt;/overline&gt;
        &lt;foreground&gt;#007F0E&lt;/foreground&gt;
    &lt;/format&gt;
    &lt;format id="python:definition" &gt;
        &lt;bold&gt;true&lt;/bold&gt;
    &lt;/format&gt;
&lt;/QXF&gt;
</pre>

<p>The results is the following highlighting:</p>
<img src="format_example.png" border=1>

<h1 id="CHANGELOG">Changelog</h1>

<p>The changelog can be found in the <a href="https://github.com/texstudio-org/texstudio/blob/master/utilities/manual/CHANGELOG.txt">Github repository</a>.</p>

</body></html>
